Skip to content Skip to sidebar Skip to footer

Out Of Memory Error Android Due To Fragmentation After 20+days

I made a application that runs on a coffee machine.After 20+ days (can be 60+ days depending on use) an OutOfMemoryError occurs: java.lang.OutOfMemoryError: Failed to allocate

Solution 1:

Is there a way to run a defragmentation on memory android application programmatically?

No. On Android 5.0-7.1, the best thing that you can do is get out of the foreground, as ART's garbage collector will compact memory only when your app is in the background. On Android 8.0+, ART's garbage collector will compact memory even while you are in the foreground.

Beyond that, aim to start a fresh process once per week or something, so you get a fresh heap.

Post a Comment for "Out Of Memory Error Android Due To Fragmentation After 20+days"