AndroidDevMetrics icon indicating copy to clipboard operation
AndroidDevMetrics copied to clipboard

OutOfMemoryError

Open Maragues opened this issue 8 years ago • 2 comments

I'm seeing this OOM after ~6 hours of running an application

Clamp target GC heap from 96.827MB to 96.000MB
GC_BEFORE_OOM freed 73K, 8% free 90855K/98304K, paused 566ms, total 566ms
Out of memory on a 2097168-byte allocation.
"MyInteractorThread" prio=5 tid=17 RUNNABLE
  | group="main" sCount=0 dsCount=0 obj=0x42273ad8 self=0x556c8008
  | sysTid=12621 nice=0 sched=0/0 cgrp=apps/bg_non_interactive handle=1431377544
  | state=R schedstat=( 0 0 0 ) utm=113074 stm=11704 core=1
  at java.util.HashMap.makeTable(HashMap.java:~569)
  at java.util.HashMap.doubleCapacity(HashMap.java:589)
  at java.util.HashMap.put(HashMap.java:419)
  at com.frogermcs.androiddevmetrics.internal.metrics.InitManager.putInitMetric(InitManager.java:60)
  at com.frogermcs.androiddevmetrics.internal.metrics.InitManager.addInitMetric(InitManager.java:55)
  at com.frogermcs.androiddevmetrics.aspect.Dagger2GraphAnalyzer.logAndExecute(Dagger2GraphAnalyzer.java:71)
  at com.mycompany.dagger.PreferencesModule.provideMyPrefsProvider(PreferencesModule.java:29)
  at com.mycompany.dagger.PreferencesModule_ProvideMyPrefsProviderFactory.get(PreferencesModule_ProvideMyPrefsProviderFactory.java:24)
  at com.mycompany.dagger.PreferencesModule_ProvideMyPrefsProviderFactory.get(PreferencesModule_ProvideMyPrefsProviderFactory.java:8)
  at com.mycompany.dagger.DaggerAppComponent.myPrefsPreferences(DaggerAppComponent.java:370)
  at com.mycompany.bluetooth.response_processing.DataBlockMediator.processDataBlock(DataBlockMediator.java:93)
  at com.mycompany.bluetooth.response_processing.DataBlockMediator.onNewDataBlock(DataBlockMediator.java:53)
  at com.mycompany.bluetooth.ResponseMediator.onNewDataBlock(ResponseMediator.java:162)
  at com.mycompany.bluetooth.response_processing.processor.shared.SharedDataProcessor.propagateDataBlock(SharedDataProcessor.java:66)
  at com.mycompany.bluetooth.response_processing.processor.shared.SharedDataProcessor.process(SharedDataProcessor.java:57)
  at com.mycompany.bluetooth.ResponseMediator.onNewParsedMessage(ResponseMediator.java:98)
  at com.mycompany.bluetooth.ResponseMediator$$Lambda$1.accept((null):-1)
  at io.reactivex.internal.operators.flowable.FlowableDoOnEach$DoOnEachSubscriber.onNext(FlowableDoOnEach.java:85)
  at io.reactivex.processors.UnicastProcessor.drainRegular(UnicastProcessor.java:213)
  at io.reactivex.processors.UnicastProcessor.drain(UnicastProcessor.java:289)
  at io.reactivex.processors.UnicastProcessor.onNext(UnicastProcessor.java:352)
  at com.mycompany.bluetooth.response_processing.parser.ResponseParser.onFinalState(ResponseParser.java:139)
  at com.mycompany.bluetooth.response_processing.parser.ResponseParser.parseByte(ResponseParser.java:127)
  at com.mycompany.bluetooth.response_processing.parser.ResponseParser$$Lambda$1.accept((null):-1)
  at io.reactivex.internal.operators.flowable.FlowableDoOnEach$DoOnEachSubscriber.onNext(FlowableDoOnEach.java:85)
  at io.reactivex.processors.PublishProcessor$PublishSubscription.onNext(PublishProcessor.java:316)
  at io.reactivex.processors.PublishProcessor.onNext(PublishProcessor.java:198)
  at com.mycompany.bluetooth.response_processing.parser.ResponseParser.lambda$parse$0(ResponseParser.java:108)
  at com.mycompany.bluetooth.response_processing.parser.ResponseParser$$Lambda$2.accept((null):-1)
  at io.reactivex.internal.operators.observable.ObservableDoOnEach$DoOnEachObserver.onNext(ObservableDoOnEach.java:95)
  at io.reactivex.internal.operators.observable.ObservableRange$RangeDisposable.run(ObservableRange.java:64)
  at io.reactivex.internal.operators.observable.ObservableRange.subscribeActual(ObservableRange.java:35)
  at io.reactivex.Observable.subscribe(Observable.java:10841)
  at io.reactivex.internal.operators.observable.ObservableDoOnEach.subscribeActual(ObservableDoOnEach.java:42)
  at io.reactivex.Observable.subscribe(Observable.java:10841)
  at io.reactivex.Observable.subscribe(Observable.java:10827)
  at io.reactivex.Observable.subscribe(Observable.java:10705)
  at com.mycompany.bluetooth.response_processing.parser.ResponseParser.parse(ResponseParser.java:109)
  at com.mycompany.bluetooth.ResponseMediator.processResponse(ResponseMediator.java:71)
  at com.mycompany.bluetooth.MyFacadeImpl$BTHandler.handleMessage(MyFacadeImpl.java:529)
  at android.os.Handler.dispatchMessage(Handler.java:102)
  at android.os.Looper.loop(Looper.java:136)
  at android.os.HandlerThread.run(HandlerThread.java:61)

We provide preferences through Dagger2 and we were not using @Singleton, so I'm guessing that androiddevmetrics annotated that initialization, and since we receive information every 250ms and update several preferences, it quickly exhausted the heap.

In any case, I'd say that shouldn't be happening. While for other apps it may not cause an OOM, it definitely is using memory.

Maragues avatar Apr 14 '17 07:04 Maragues

After some more testing I'm still seeing the OOM, so it might not be related to this library

Maragues avatar Apr 14 '17 10:04 Maragues

Analyzing the hprof after 3 hours, it does look like the library is the one exhausting the memory

image

image

image

Maragues avatar Apr 14 '17 11:04 Maragues