Android Question HttpJob ERROR java.lang.OutOfMemoryError

ivanomonti

Expert
Licensed User
Longtime User
load record metod post

B4X:
    Dim sh As String = "http://www.mysite.com/myUsersList"
    HttpAgent.Initialize("getuserslist", Me)
    HttpAgent.PostString(sh,"pagindex=" & page)
    Utils.SetAuthCookie(HttpAgent.GetRequest)

When i load multiple list making simultaneous requests, I get this error, and can avoid this problem.

B4X:
main_jobdone (B4A line: 186)
Log(Job.GetString)
java.lang.OutOfMemoryError
   at java.lang.AbstractStringBuilder.enlargeBuffer(AbstractStringBuilder.java:94)
   at java.lang.AbstractStringBuilder.append0(AbstractStringBuilder.java:114)
   at java.lang.StringBuilder.append(StringBuilder.java:249)
   at anywheresoftware.b4a.objects.streams.File$TextReaderWrapper.ReadAll(File.java:568)
   at anywheresoftware.b4a.samples.httputils2.httpjob._getstring2(httpjob.java:159)
   at anywheresoftware.b4a.samples.httputils2.httpjob._getstring(httpjob.java:144)
   at b4a.example.main._jobdone(main.java:977)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:511)
   at anywheresoftware.b4a.BA.raiseEvent2(BA.java:170)
   at anywheresoftware.b4a.keywords.Common$5.run(Common.java:958)
   at android.os.Handler.handleCallback(Handler.java:615)
   at android.os.Handler.dispatchMessage(Handler.java:92)
   at android.os.Looper.loop(Looper.java:137)
   at android.app.ActivityThread.main(ActivityThread.java:4898)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:511)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1008)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:775)
   at dalvik.system.NativeStart.main(Native Method)
Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1), thread 17355 (samsungani)

Thank
 

ivanomonti

Expert
Licensed User
Longtime User
18 record (field 10 max 255 chr) with its image 64x64 base64 to every request sent to the socket
 
Upvote 0

gudino jose luis

Active Member
Licensed User
Longtime User
B4X:
** Service (httputils2service) Start **
** Activity (principal) Pause, UserClosed = false **


** Activity (principal) Resume **
Response from server: [{"imei":"355143040471475","cid_empre":"36","cactivo":"1"}]
Response from server: [{"idSqlLog":"233397","csentenciaSql":"INSERT INTO tlineas VALUES( DEFAULT ,'001','MOTOR','36')","cbasedatos":"bdemp36","ctabla":"tlineas","dactualizacion":"2014-08-04 18:40:04","empresa":null}................
WakeLock already held.
WakeLock already held.
java.lang.OutOfMemoryError
    at java.lang.AbstractStringBuilder.enlargeBuffer(AbstractStringBuilder.java:95)
    at java.lang.AbstractStringBuilder.append0(AbstractStringBuilder.java:115)
    at java.lang.StringBuilder.append(StringBuilder.java:250)
    at anywheresoftware.b4a.objects.streams.File$TextReaderWrapper.ReadAll(File.java:590)
    at confia.movil.httpjob._getstring2(httpjob.java:179)
    at confia.movil.httpjob._getstring(httpjob.java:164)
    at confia.movil.principal._jobdone(principal.java:5169)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:507)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:174)
    at anywheresoftware.b4a.keywords.Common$5.run(Common.java:952)
    at android.os.Handler.handleCallback(Handler.java:587)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:130)
    at android.app.ActivityThread.main(ActivityThread.java:3687)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:507)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
    at dalvik.system.NativeStart.main(Native Method)** Service (httputils2service) Start **
** Activity (principal) Pause, UserClosed = false **
Hi!
I have the same problem:

I'm making a query to a database that has 19,000 records using the service httputils2service

when using a table of samsumg galaxi tab 3 works perfectly, but when I run the query samsumg galaxi tab 1 Then the next error message:
Hi!
I have the same problem:

I'm making a query to a database that has 19,000 records using the service httputils2service

when using a table of samsumg galaxi tab 3 works perfectly, but when I run the query samsumg galaxi tab 1 Then the next error message:
 
Upvote 0

gudino jose luis

Active Member
Licensed User
Longtime User
Perfect, Erel

I will make the query into several part, I think that if I put for example

"select * from emplesas LIMIT 1000" , in this way make a pagination of 1000 in 1000 each query. thanks for the help, Greetings
 
Upvote 0

keirS

Well-Known Member
Licensed User
Longtime User
Quick question Erel. Surely it would be possible to have a sub in HttpUtils2 that returns a pointer to the file that is generated by the request? Or perhaps even better a sub which passes a directory and filename for the file to be copied to. Unless I am reading the error wrong the crash is when reading the response into the TextReader in the GetString2 sub and nothing to do with the actual response to the request.
 
Upvote 0
Top