1

I'm working on a project that's using Android Media Projection. I'm seeing a rather large memory leak in native code (the app jvm memory usage is fairly low and stable). I've been able get native memory dumps, and I see a bunch of 4Mb buffers that appear to be allocated from opengl. The app doesn't interact directly with opengl (but I'm fairly sure the media projection is). If we shut down the media projection, and start it again (and we do release the virtual display when we stop), we get more of these 4Mb buffers, and soon crash.

The heap dump has a bunch of these:

z 1  sz  4194304  num   16  bt abab7645 9f562deb 9f5616ec 9f561614 91c8caab ae451985 ae450907 ae44ee05 ae4561c1 ae4548a0 aea5191f abdc3041 ac7bc189 ac7aba69 ac7bce52 ac7bdc51

Where those addresses map the following libraries (but I don't have symbols for those libraries AFAIK).

/system/lib/libc.so
/system/lib/libOpenglSystemCommon.so
/system/lib/libOpenglSystemCommon.so
/system/lib/libOpenglSystemCommon.so
/system/lib/hw/gralloc.ranchu.so
/system/lib/libui.so
/system/lib/libui.so
/system/lib/libui.so
/system/lib/libui.so
/system/lib/libui.so
/system/lib/libandroid_runtime.so
/system/lib/libbinder.so
/system/lib/libgui.so
/system/lib/libgui.so
/system/lib/libgui.so
/system/lib/libgui.so

Edit: I've made a sample project that demo's the issues:

https://github.com/johngray1965/MediaProjectorSample

Follow the instructions in the README. After a few iterations I ended using 42Mb (Most of which is 9 4Mb buffers). That's with the media projector stopped. This is for an app that's doing very little. In the real world there are additional memory demands on top of this. And that's just for the native usage, that doesn't take into consideration the JVM memory usage.

johngray1965
  • 163
  • 1
  • 9

0 Answers0