How to find the origin of GC_FOR_MALLOC?

I am working on an android application that falls into the endless GC_FOR_MALLOC loop:

06-15 11:24:56.685: DEBUG/dalvikvm(118): GC_FOR_MALLOC freed 4136 objects / 374744 bytes in 66ms 06-15 11:24:59.176: DEBUG/dalvikvm(521): GC_FOR_MALLOC freed 9340 objects / 524152 bytes in 645ms 06-15 11:24:59.846: DEBUG/dalvikvm(521): GC_FOR_MALLOC freed 9344 objects / 524328 bytes in 149ms 06-15 11:25:01.535: DEBUG/dalvikvm(521): GC_FOR_MALLOC freed 9346 objects / 524448 bytes in 193ms 06-15 11:25:02.175: DEBUG/dalvikvm(521): GC_FOR_MALLOC freed 9344 objects / 524344 bytes in 126ms 

The application read some jpeg image through a socket (dedicated stream) and displayed it in imageView. The GC loop suppresses the image display.

Is there a solution to find out which line, or at least which part of the code throws the garbage collection?

thanks

+4
source share
1 answer

I'm not sure that you can access the virtual machine and check why it runs gc all the time, but gc usually runs when there is a need for it. You should check that it uses so much memory. It could be uploading your image (is it a large image?) Or maybe it is something else in your application. Check out this post on how to analyze your memory usage and while you check for memory leak on it.

+2
source

All Articles