[android-developers] Memory usage problem - leak?
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!
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home