RequestQueue generating java.lang.OutOfMemoryError

1,314 views
Skip to first unread message

Santiago Martínez

unread,
May 29, 2014, 11:04:11 AM5/29/14
to volley...@googlegroups.com
Hi guys,

I just ported my app to Volley and I am having a hard time with Threads. I use one Singleton that delivers the same RequestQueue to the whole application so I just cancel the request
in the Fragments when the Fragment get's destroyed.

My problem is, after a Request is finished, the threads associated to it seems to remain in the "Wait" status forever, so eventually the number of threads in Wait gets to big and I end up getting:

java.lang.OutOfMemoryError: pthread_create (stack size 16384 bytes) failed: Try again


I use the default RequestQueue by calling Volley.newRequestQueue(), and this I how I add the request:

    public void addToQueue(GsonRequest request) {
        if (request != null) {
            request.setTag(this);
            if (mRequestQueue == null)
                mRequestQueue = VolleyS.getInstance(mContext).getRequestQueue(); // This returns always the same Queue created with Volley.newRequestQueue(context)
            mRequestQueue.add(request);
        }
    } 

Does anyone have an idea of what am I doing wrong?

Thank you very much! 

Ficus Kirkpatrick

unread,
May 29, 2014, 1:43:56 PM5/29/14
to Santiago Martínez, volley...@googlegroups.com
Volley starts its threads once when you make the RQ, so it looks like you are spawning threads somewhere else and leaking them.


--
You received this message because you are subscribed to the Google Groups "Volley Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to volley-users...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Santiago Martínez

unread,
May 30, 2014, 6:36:19 AM5/30/14
to volley...@googlegroups.com, sa...@gpmess.com
Thanks a lot, you where right. There was a newRequestQueue going arround one static call in a helper class downloading some street names and that was the one leaking threads.


Thank you very much!

chinthaka devinda

unread,
Apr 16, 2018, 4:09:39 AM4/16/18
to Volley Users
Any solution for this I am facing the same issue.
Reply all
Reply to author
Forward
0 new messages