How can I free Drawable memory in one Android Honeycomb Activity after a different Activity has started?

Also for me OnPause event is a better place where put your "memory-free" code.

Also for me OnPause event is a better place where put your "memory-free" code. Here the event flow when you open a child activity from a parent activity -- Open caller activity -- ActCaller 1311090884303: onCreate ActCaller 1311090884572: onStart ActCaller 1311090884699: onPostCreate savedInstanceState null ActCaller 1311090884802: onResume ActCaller 1311090884908: onPostResume -- Open child activity -- ActCaller 1311090926270: onSaveInstanceState ActCaller 1311090926374: onPause ActChild 1311090926556: onCreate ActChild 1311090926703: onStart ActChild 1311090926807: onPostCreate savedInstanceState null ActChild 1311090926911: onResume ActChild 1311090927014: onPostResume ActCaller 1311090927508: onStop As you already noticed, parent's onStop is called only after complete child creation. What about calling memory-free code from two different location?

Consider that dialogs, generally, don't completely cover calling activity, so preserving it's background has a sense. Maybe a flag can be set when you open a new activity instead of a dialog, and OnPause logic will drop background only when a new activity is launched, and not a dialog.

That's actually very helpful generally, thank you—the interlocking of two activity lifecycles isn't very well documented that I can see! My only slight concern is that using onPause() might end up removing the drawable in circumstances where I don't want it removed. I guess I can only try it though :) – Andrew Wyld Oct 25 '11 at 10:31.

There is no special way for handling such things, it's regular java way: Objects are garbage collected at an unknown time in future if they are no longer referenced. Just don't keep a reference to anything you don't need, and you will be fine. Check this video for great info on this: youtube.com/watch?v=_CruQY55HOk.

That doesn't work in this case: I have removed all explicit references to these objects, but in one case some implicit references are kept. In one situation the method I have described for getting rid of the implicit references works; in another situation, it doesn't. I am trying to work out why, because I need to remove these implicit references.

– Andrew Wyld Oct 25 '11 at 10:27 @AndrewWyld: Use MAT to determine exactly what the "implicit reference" is. – CommonsWare Oct 25 '11 at 11:17 I have done and can tell you: the background LinearLayout contains a reference to a Bitmap (as described in the original question). Calling setBackgroundDrawable(null) from onStop() frees this reference if you hit the power button (triggering a sleep state) but not if you launch another Activity with an Intent; however it does work from onPause().

This suggests you can't change the background of a View when it's not part of the active context, so purging memory from onStop() doesn't work. – Andrew Wyld Oct 25 '11 at 11:54.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions


Thank You!
send