Android – after I made a lot of requests with a lot of data, volley gave me a memory exception

I have a page viewer. I have a list view in each page. This list view will have 10 records of using web services. Therefore, the page viewer uses three web service calls to fill three pages (currently, left and right). After I slide a lot, I get this exception:

java.lang.OutOfMemoryError: pthread_create (stack size 16384 bytes) Failed: Try again
            at java.lang.VMThread.create(Native Method)
            at java.lang.Thread.start(Thread.java:1029)
            at com.android.volley.RequestQueue.start(RequestQueue.java:142)
            at com.android.volley.tool@R_608_2419@.Volley.newRequestQueue(Volley.java:66)
            at com.android.volley.tool@R_608_2419@.Volley.newRequestQueue(Volley.java:78)
            at com.imona.android.entities.Record.<init>(Record.java:57)
            at com.imona.android.webservices.OperationalDataRest$1.onResponse(OperationalDataRest.java:109)
            at com.imona.android.webservices.OperationalDataRest$1.onResponse(OperationalDataRest.java:85)
            at com.android.volley.tool@R_608_2419@.JsonRequest.deliverResponse(JsonRequest.java:65)
            at com.android.volley.ExecutorDelivery$ResponseDeliveryRunnable.run(ExecutorDelivery.java:99)
            at android.os.Handler.handleCallback(Handler.java:733)
            at android.os.Handler.dispatchMessage(Handler.java:95)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5017)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
            at dalvik.system.NativeStart.main(Native Method) 

resolvent:

How do you initialize your requestqueue? I suspect you are creating requestqueues for each tab. If this is the case, change the program to use a common instance of requestqueue in all tabs. You need to initialize and keep it in the activity and add requests to it from each tab

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>