I've seen many discussions on freeing Bitmaps, but I don't think I have ever
seen a definitive answer on the proper method of doing it.
I have an activity which creates a custom class, and the custom class has a
clear method, which I call before freeing the class.
Below is the code from my custom class, and, and following it is the code
from the OnDestroy event . Is this sufficient to make sure I am not leaking
memory? Note that it is untested code right now, so may contain a few
spelling mistakes.
public class JSONDataTable
{
public ArrayList<Bitmap> BitmapArray;
...
Methods etc.
..
public void Clear()
{
if (BitmapArray != null)
{
for (int i = BitmapArray.size() - 1; i > -1 ; i-- )
{
BitmapArray.set(i, null);
BitmapArray.remove(i);
}
}
BitmapArray = null;
}
}
FROM THE ACTIVITY
protected void onDestroy()
{
if (JSONProductTable != null) {
JSONProductTable.Clear();
JSONProductTable = null;
}
}
Sincerely,
Brad Gies
-----------------------------------------------------------------
Brad Gies
27415 Greenfield Rd, # 2,
Southfield, MI, USA
48076
-----------------------------------------------------------------
Moderation in everything, including abstinence
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---