facebookarchive / network-connection-class

Listen to current network traffic in the app and categorize the quality of the network.
Other
3.19k stars 515 forks source link

OutofMemoryException while sampling #38

Closed Saurak closed 6 years ago

Saurak commented 6 years ago

Sampling using DeviceBandwidthSampler.getInstance().startSampling() leading to oom on several devices

Fatal Exception: java.lang.OutOfMemoryError Failed to allocate a 12 byte allocation with 0 free bytes and 3GB until OOM keyboard_arrow_up android.os.StrictMode.allowThreadDiskReads (StrictMode.java:1022) arrow_right com.facebook.network.connectionclass.QTagParser.parseDataUsageForUidAndTag (SourceFile:75) com.facebook.network.connectionclass.DeviceBandwidthSampler$SamplingHandler.addSample (SourceFile:117) com.facebook.network.connectionclass.DeviceBandwidthSampler$SamplingHandler.handleMessage (SourceFile:100) android.os.Handler.dispatchMessage (Handler.java:102) android.os.Looper.loop (Looper.java:148) android.os.HandlerThread.run (HandlerThread.java:61)

SeyelentEco commented 6 years ago

QTagParser doesn't exist anymore. Are you running an older version?

SeyelentEco commented 6 years ago

Also, it's likely you have another memory leak elsewhere. Usually any code that allocates any memory (in this case 12 bytes), has the potential to trigger an Out of Memory error. It's usually not the cause of the leak though. I suggest doing an HPROF dump of your application and seeing what classes are being held in memory. Usually it's activities or large bitmaps.