android


Multiple enqueue in retrofit causing out of memory error?


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)
Thanks in advance.
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.
I am using Retrofit 2.0.2, and i have this tag in my manifest file:
android:largeHeap="true"
I am retrying on failure like this:
#Override
public void onFailure(Call<AudioResponse> call, Throwable error) {
loading.setVisibility(View.GONE);
if (mAdapter.getItemCount() == 0) {
SetErrorContent();
}
Log.e("Error", error.getMessage() + "");
call.cancel();
call.clone().enqueue(this);
}
It is not crashing.Give it a try.

Related Links

How to create a custom browser in android
compare the pixel of the two different images , takes too long time
Android application session management
Use phonegap features in my WebView
Is there a “correct” way to store an application's login session?
Toast background changing to match Activity's Theme
Application force close when trying to close SQLite database
How to parse Text and Images from this [duplicate]
Date Preference exist?
implement projectile motion. android
Publish apps on android market [closed]
Write values dynamically to html file stored inside assets folder
Android draw9patch: static area gone
Image/Bitmap placement?
Upgrading and existing flex application using the mx library to work on Android
The method startActivity(Intent) is undefined for the type?

Categories

HOME
windows
fpga
ecmascript-6
phpmyadmin
oracle-apex-5
database-normalization
simulink
alsa
jax-ws
angularfire2
extjs4.2
categorical-data
windows-ce
plink
screen-readers
capistrano3
null-pointer
mathprog
jmp
solrcloud
exploit
inversion-of-control
sqlpackage
nsurl
linkedhashmap
installshield-le
sendbird
vue-chartjs
html-encode
jwplayer6
yowsup
batching
numpy-broadcasting
hivemq
openerp-7
sql-server-ce
amazon-ses
stringtokenizer
android-softkeyboard
naming
knime
oim
ntvs
user-defined-fields
tinymce-3
activeperl
posixct
google-cse
reindex
context-switch
subnet
oracleclient
filehandle
jqchart
otp
flyout
offline.js
choice
gets
cronexpression
reporting-services-2012
mongodb-php
synonym
lean
kango-framework
stream-processing
kiosk
httpruntime.cache
mobiledoc-kit
forwarding
jsvc
airbrake
keyup
openbabel
document-repository
packet-sniffers
ghcjs
wcm
lambda-architecture
synapse
script#
cffile
isa-swizzling
cloudfiles
dot-emacs
isapi-extension
todos
sqlobject
ifilter

Resources

Encrypt Message