Hello,

In my app, I'm fetching data via HTTP and use the response string to create
an ArrayList of objects. So what I'm doing once I get the response is:

String[] fields = response.split("<field>");

and use the field[] values like this:

ArrayList<Movie> movies = new ArrayList<Movie>();
for (int row = 1; row < fields.length; row += 9) {
   movies.add(new Movie(fields[row], fields[row + 1], ..., fields[row + 8]);
}

Now, when I load the heap dump of the app into Eclipse's Memory Analyzer
Tool[1], the response string still shows up (about 800KB - 28%), as well as
the ArrayList (245KB - 8.7%). I suppose the size of the ArrayList is about
right, since some of the field values are stored as integers and there is no
overhead of the <field></field> tags.

But I don't understand why the response string is still living. I've tried
setting response = null after creating the array, but it still shows up.
Shouldn't it be GCed? Then when I go back to my home activity, leaving the
activity that fetched the data and kept the ArrayList in its adapter, both
objects *still* show up. Does that mean there is a leak somewhere? Android
is supposed to destroy a closed activity and its references (if not
referenced elsewhere), right?

I've read Romain's blog entry about memory leaks and some more other blog
entries like this[2] and this[3] one but I still can't figure this out. My
real code can be found here[4].

Suggestions and hints appreciated!


[1]
http://kohlerm.blogspot.com/2009/04/analyzing-memory-usage-off-your-android.html
[2] http://java.dzone.com/news/how-fix-memory-leaks-java
[3] http://kohlerm.blogspot.com/2009/02/memory-leaks-are-easy-to-find.html
[4]
http://code.google.com/p/android-xbmcremote/source/browse/trunk/XBMC%20Remote/src/org/xbmc/httpapi/client/VideoClient.java#221

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to