B4J Question CPU up to 100%

tchart

Well-Known Member
Licensed User
Longtime User
Erel, just had something weird happen with B4J

I had some JSON that was wanting to use in a string builder - I have a script in Notepad++ that converts raw JSON to string builder lines.

Anyway, I pasted the following into a sub in B4J before I had dimmed sb (as StringBuilder). The CPU shot up to 100% and hung there until I managed to (slowly) type out the Dim sb as...

The IDE is almost non-responsive when this happened. I tested it again in a new project and same thing.

Just thought I would let you know - obviously the correct way is to Dim the string builder first but the mistake in workflow caused the odd behaviour.

B4X:
sb.Append("{")
sb.Append("""displayFieldName"" : """",")
sb.Append("""fieldAliases"" : {")
sb.Append("""OBJECTID"" : ""OBJECTID""")
sb.Append("},")
sb.Append("""geometryType"" : ""esriGeometryPolygon"",")
sb.Append("""spatialReference"" : {")
sb.Append("""wkid"" : 2193,")
sb.Append("""latestWkid"" : 2193")
sb.Append("},")
sb.Append("""fields"" : [")
sb.Append("{")
sb.Append("""name"" : ""OBJECTID"",")
sb.Append("""type"" : ""esriFieldTypeOID"",")
sb.Append("""alias"" : ""OBJECTID""")
sb.Append("}")
sb.Append("],")
sb.Append("""features"" : [")
sb.Append("{")
sb.Append("""attributes"" : {")
sb.Append("""OBJECTID"" : 1")
sb.Append("},")
sb.Append("""geometry"" : {")
sb.Append("""rings"" : [[[truncated for readability]]]")
sb.Append("}")
sb.Append("}")
sb.Append("]")
sb.Append("}")
 

jmon

Well-Known Member
Licensed User
Longtime User
Are you sure it is caused by the IDE? Not something else running in the background? I copied your example code to B4J's IDE and didn't see any slowdown.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
It runs properly here.

I have a script in Notepad++ that converts raw JSON to string builder lines.
This is not necessary at all.

You can use the smart string literal:
B4X:
Dim s As String = $"
kljhf lkwejg lkwje g
w egweg powjog woepg 
w" wegf wg weg W" Wegwegweg weg wegw egw eg"WEG we
g w
eg weG"W g'W Eg"W eg"W g'WE GWE{
"$
 
Upvote 0
Top