Closed PraveenSheroes closed 6 years ago
Do you have a stacktrace?
Caused by java.lang.OutOfMemoryError: Failed to allocate a 79288 byte allocation with 46080 free bytes and 44KB until OOM at java.lang.AbstractStringBuilder.enlargeBuffer(AbstractStringBuilder.java:95) at java.lang.AbstractStringBuilder.append0(AbstractStringBuilder.java:146) at java.lang.StringBuffer.append(StringBuffer.java:219) at java.io.StringWriter.write(StringWriter.java:147) at java.io.StringWriter.append(StringWriter.java:199) at java.io.StringWriter.append(StringWriter.java:30) at com.google.gson.stream.JsonWriter.beforeValue(JsonWriter.java:651) at com.google.gson.stream.JsonWriter.value(JsonWriter.java:481) at com.google.gson.internal.bind.TypeAdapters$3.write(TypeAdapters.java:165) at com.google.gson.internal.bind.TypeAdapters$3.write(TypeAdapters.java:151) at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.write(TypeAdapterRuntimeTypeWrapper.java:69) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.write(ReflectiveTypeAdapterFactory.java:125) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.write(ReflectiveTypeAdapterFactory.java:243) at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.write(TypeAdapterRuntimeTypeWrapper.java:69) at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.write(CollectionTypeAdapterFactory.java:97) at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.write(CollectionTypeAdapterFactory.java:61) at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.write(TypeAdapterRuntimeTypeWrapper.java:69) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.write(ReflectiveTypeAdapterFactory.java:125) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.write(ReflectiveTypeAdapterFactory.java:243) at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.write(TypeAdapterRuntimeTypeWrapper.java:69) at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.write(CollectionTypeAdapterFactory.java:97) at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.write(CollectionTypeAdapterFactory.java:61) at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.write(TypeAdapterRuntimeTypeWrapper.java:69) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.write(ReflectiveTypeAdapterFactory.java:125) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.write(ReflectiveTypeAdapterFactory.java:243) at com.google.gson.Gson.toJson(Gson.java:669) at com.google.gson.Gson.toJson(Gson.java:648) at com.google.gson.Gson.toJson(Gson.java:603) at com.google.gson.Gson.toJson(Gson.java:583) at appliedlife.pvtltd.SHEROES.preferences.GsonConverter.serialize(GsonConverter.java:24) at com.f2prateek.rx.preferences2.ConverterAdapter.set(ConverterAdapter.java:25) at com.f2prateek.rx.preferences2.RealPreference.set(RealPreference.java:72) at appliedlife.pvtltd.SHEROES.presenters.FeedPresenter$2.onNext(FeedPresenter.java:271) at appliedlife.pvtltd.SHEROES.presenters.FeedPresenter$2.onNext(FeedPresenter.java:253) at io.reactivex.observers.SerializedObserver.onNext(SerializedObserver.java:111) at io.reactivex.internal.operators.observable.ObservableTakeUntil$TakeUntilObserver.onNext(ObservableTakeUntil.java:87) at io.reactivex.internal.operators.observable.ObservableObserveOn$ObserveOnObserver.drainNormal(ObservableObserveOn.java:200) at io.reactivex.internal.operators.observable.ObservableObserveOn$ObserveOnObserver.run(ObservableObserveOn.java:252) at io.reactivex.android.schedulers.HandlerScheduler$ScheduledRunnable.run(HandlerScheduler.java:109) at android.os.Handler.handleCallback(Handler.java:815) at android.os.Handler.dispatchMessage(Handler.java:104) at android.os.Looper.loop(Looper.java:214) at android.app.ActivityThread.main(ActivityThread.java:6102) at java.lang.reflect.Method.invoke(Method.java) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1028) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823)
Failed to allocate a 79288 byte allocation with 46080 free bytes and 44KB until OOM
I doubt this is an issue in rx-preferences or even GSON. You only had 44kb of memory left. Something else in your application is using up this memory.
But I am getting this OutOfMemoryError only GsonConverter.serialize(), this method used for RxSharedPreferences
@Singleton
@Provides
public Preference
public class GsonConverter implements Preference.Converter {
final Gson gson;
private String json;
private Class clazz;
public GsonConverter(Gson gson, Class clazz) {
this.gson = gson;
this.clazz = clazz;
}
@NonNull @Override public T deserialize(@NonNull String serialized) {
return gson.fromJson(serialized, clazz);
}
}