改造中的多个排队导致内存不足错误? [英] Multiple enqueue in retrofit causing out of memory error?

查看:82
本文介绍了改造中的多个排队导致内存不足错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用改造 2 进行我的项目.当我的呼叫继续失败时,我再次重复相同的呼叫.此呼叫的重复使我的应用程序强制关闭.当我查看日志时,我得到了错误日志,如下所示.我觉得这是由多个排队到同一个呼叫引起的.所以我在 enqueus 之前这样做了,我打电话给取消.但它不起作用.接近相同的力.

Am doing my project using retrofit2. When my Call goes on failure i repeat same call again.Repeation of this call made my app to force close. When i look on log i got error log, which is given below. I felt this is caused by multiple enqueue to same Call. So i did that before enqueus i called cancel. But its not working. getting same force close.

FATAL EXCEPTION: main
Process: com.SocialMob, PID: 27846
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 java.util.concurrent.ThreadPoolExecutor.addWorker(ThreadPoolExecutor.java:920)
at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1338)
at okhttp3.Dispatcher.enqueue(Dispatcher.java:112)
at okhttp3.RealCall.enqueue(RealCall.java:78)
at okhttp3.RealCall.enqueue(RealCall.java:70)
at retrofit2.OkHttpCall.enqueue(OkHttpCall.java:104)
at retrofit2.ExecutorCallAdapterFactory$ExecutorCallbackCall.enqueue(ExecutorCallAdapterFactory.java:58)
at com.SocialMob.Activities.SplashActivity.VersionCheck(SplashActivity.java:184)
at com.SocialMob.Activities.SplashActivity.access$500(SplashActivity.java:38)
at com.SocialMob.Activities.SplashActivity$1.onFailure(SplashActivity.java:177)
at retrofit2.ExecutorCallAdapterFactory$ExecutorCallbackCall$1$2.run(ExecutorCallAdapterFactory.java:75)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5593)
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:1283)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
at dalvik.system.NativeStart.main(Native Method)

提前致谢.

推荐答案

您应该避免这种方法,因为它会导致递归调用.相反,您应该首先检查失败函数中的原因,然后重试.同时修复重试次数.

You should avoid that approach, as it would make it a recursive call. Instead you should check the cause in the failure function first and then retry. Also fix the number of retry times.

这篇关于改造中的多个排队导致内存不足错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆