I'm starting a service => background service, And starting a check for files in "new Thread", In the log i'm getting the following, the service/app gets paused .
Log : I/art: Explicit concurrent mark sweep GC freed 25935(1686KB) AllocSpace objects, 13(903KB) LOS objects, 39% free, 13MB/22MB, paused 649us total 43.569ms
It's just a scan for files in MyData in SDcard, which contain a bunch of pics ( about 20 pics ) .
**Scan = Getting the pics names and saving them to String .
All this means is that the garbage collector is doing its job and freeing up memory.
If you are seeing this frequently (or consistently), then you are likely allocating too many objects. A common cause is allocating many (or a few large) objects within a loop like so:
for (int i = 0; i < 100; i++) {
Bitmap bmp = Bitmap.create(100, 100, Bitmap.Config.ARGB_4444);
}
Every time we hit this loop, we allocate one hundred new Bitmap objects.
The best way to prevent GC sweeps is to not allocate objects. Of course you have to allocate objects in Java, so you need to ensure that you are not allocating unnecessarily.
Here is one of many YouTube videos that Google has release with tips on avoiding GC events and managing memory properly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With