java - Android - Few more memory related issues -
java - Android - Few more memory related issues -
i have application has (mostly) images in layouts. understand, android supposed free memory when activity not needed anymore. thus, not releasing drawables used app's layouts when activity goes onpause() manually. understand android should this.
then, utilize code check memory status:
{ activitymanager activitymanager = (activitymanager) context.getsystemservice(context.activity_service); android.app.activitymanager.memoryinfo memoryinfo = new activitymanager.memoryinfo(); activitymanager.getmemoryinfo(memoryinfo); log.i("memcheck", " memoryinfo.availmem " + memoryinfo.availmem + "\n" ); log.i("memcheck", " memoryinfo.lowmemory " + memoryinfo.lowmemory + "\n" ); log.i("memcheck", " memoryinfo.threshold " + memoryinfo.threshold + "\n" ); android.os.debug.memoryinfo[] memoryinfoarray = activitymanager.getprocessmemoryinfo(pids); for(android.os.debug.memoryinfo pidmemoryinfo: memoryinfoarray) { log.i("memcheck", " pidmemoryinfo.gettotalprivatedirty(): " + pidmemoryinfo.gettotalprivatedirty() + "\n"); log.i("memcheck", " pidmemoryinfo.gettotalpss(): " + pidmemoryinfo.gettotalpss() + "\n"); log.i("memcheck", " pidmemoryinfo.gettotalshareddirty(): " + pidmemoryinfo.gettotalshareddirty() + "\n"); }
on every created activity, memory footprint grows (the heap - gettotalprivatedirty() ). don't wanna since every 'kb' of memory in app important.
also, when callback processed:
camera.picturecallback mpicturecallback = new camera.picturecallback() { public void onpicturetaken(byte[] imagedata, photographic camera c) { } }
empty, that. heap grows 10mb 20mb. 100%. normal? how avoid?
for images , callbacks need free memory manually, instead beingness dependent on garbage collector. need take care of context of views. whereas possible assign context @ lowest level, if view used in activity, assign activity context, if listener/callback should used in view, assign view context it.
and can unbind xml drawables manually.
java android memory
Comments
Post a Comment