android - No OutOfMemoryError, but cannot load image -


i have strange (and frustrating) problem in game.

the game drawing in canvas, i'm not using layouts , other native elements. 1 root layout canvas. have implemented admob , analytics, it's disabled (and not allocating) testing.

after few levels can't load images. logcat output imageref_ashmem create failed <(null)> *number of bytes*, no outofmemoryerror.

i tried memory analyzer tool (mat), no luck. retained size after first level (at max) 10.6 mb, , 1 level before stops loading images 10.7 mb (sometime less). situation same (with different values) in emulator , in real device. comparison of hprof files taken on first level , last shows little differencies (~2kb).

same thing in ddms heap. when things going fail, have 70.30% of used memory. garbage collector shows 27% free memory. here output in logcat:

gc_concurrent freed 193k, 42% free 6680k/11363k, paused 2ms+2ms d/dalvikvm(16011): gc_concurrent freed 118k, 27% free 8396k/11363k, paused 2ms+2ms d/skia(16011): ------- imageref_ashmem create failed <(null)> 143360 d/skia(16011): ------- imageref_ashmem create failed <(null)> 1155072 d/skia(16011): ------- imageref_ashmem create failed <(null)> 450560 d/skia(16011): ------- imageref_ashmem create failed <(null)> 143360 d/skia(16011): ------- imageref_ashmem create failed <(null)> 36864 d/skia(16011): ------- imageref_ashmem create failed <(null)> 40960 

another strange thing when output debug.getnativeheapallocatedsize() console, after level it's bigger (~0.7 mb increment). mat not showing growth in memory usage. behaviour occuring on 2 different real devices.

i think have quite big memory leak. mat not showing growth , outofmemoryerror not throwing. don't know on leaks/allocations etc.

edit:

maybe i'm not using mat properly, if interested, here 2 hprof files. 1 @ first run , second 1 level before memory problem.

link zip file

security

md5 8f4ef3eeb28c1d129ac0c0ef01cc8583
sha-1 0afc1cc06527225ad3029ef2bb4ebc5fe12d02a2

android resizes images drawable folder work on different resolutions. , resize can mess image loading.

to fix this, suggest copy images (that causing issue) folders drawable-ldpi, mdpi, hdpi, xhdpi, xxhdpi , run test. should work.

side effects

negative : bigger apk size

positive : images load faster, less memory usage. run above ddms heap thingy again, notice significant drop in memory usage.


Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -