简体   繁体   中英

Android BitmapShader memory leak

I've a memory leak in my android app, that cause outOfMemory exception. I've done a memory analysis thought MAT, and the result is that there're ' 480 instances of "android.graphics.BitmapShader", loaded by "" occupy 42,611,792 (81.71%) bytes.' I'm using a lot of Bitmaps and Drawable, but in my whole project I never use BitmapShader. I guess how could I reduce the number of objects or recycle them, if I never instantiate no one of them. Thanks to everyone

Are you using a ProgressBar ? I noticed a ton of BitmapShaders in MAT for my application as well, and most of them are retained by a ProgressBar instance. I used the dominator tree view, then right-clicked on a BitmapShader instance, choosing 'Merge Shortest Paths to GC Roots' then 'exclude weak references'. Somewhere along the hierarchy that shows up is a ProgressBar.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM