The full error message is :
java.lang.OutOfMemoryError: Failed to allocate a 4722408 byte allocation with 3388440 free bytes and 3309KB until OOM, target footprint 536870912, growth limit 536870912
at java.lang.String.fastSubstring(Native Method)
at java.lang.String.substring(String.java:2030)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.BA$2.run(BA.java:370)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:237)
at android.app.ActivityThread.main(ActivityThread.java:7857)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1076)
And the processing code is :
content=Job.GetString
Job.Release
content = content.SubString(content.IndexOf("Showing all"))
Do While content.Contains("picknumber")
str = "<h4>"
content = content.SubString(content.IndexOf("<h4>") + str.Length)
dmDate = content.substring2(0,content.IndexOf("</"))
For cnt = 0 To 6
content = content.SubString(content.IndexOf("picknumber"))
content = content.SubString(content.IndexOf("value=""") + 7)
pos1 = content.IndexOf("""")
nums(cnt) = content.substring2(0,pos1)
content = content.SubString(pos1)
Next
strsql = "INSERT INTO results VALUES ('" & draw & "','" & dmDate & "','2','" & nums(0) & "','" & nums(1) & "','" & nums(2) & "','" & nums(3) & "','" & nums(4) & "','" & nums(5) & "','" & nums(6) & "')"
sqlLotto.ExecNonQuery(strsql)
str = "picknumber"
content = content.SubString(content.IndexOf("picknumber"))
For cnt = 0 To 6
content = content.SubString(content.IndexOf("picknumber"))
content = content.SubString(content.IndexOf("value=""") + 7)
pos1 = content.IndexOf("""")
nums(cnt) = content.substring2(0,pos1)
content = content.SubString(pos1)
Next
strsql = "INSERT INTO results VALUES ('" & draw & "','" & dmDate & "','2','" & nums(0) & "','" & nums(1) & "','" & nums(2) & "','" & nums(3) & "','" & nums(4) & "','" & nums(5) & "','" & nums(6) & "')"
sqlLotto.ExecNonQuery(strsql)
draw = draw + 1
Log("Draw: " & draw & " on " & dmDate)
Loop
I know the code is not very efficient, it needs reviewing! In this case the error happened on draw = 2