6

My Android app has a custom AsyncTask to make a rest call for a list of objects. I'm using Jackson to convert my response into Java and I am seeing about 30 garbage collections calls when mapping the Json via ObjectMapper.readValue(). Interestingly enough, if I make the same call a second, third, fourth time (by selecting a refresh button), there is only a single GC call. Any ideas why this is happening on the first call every time I start my Android App?

AsyncTask.java

doInBackground() {

HttpGet request = new HttpGet(url);
HttpClientUtil.setJsonAccept(request);
HttpResponse response = httpClient.execute(request);
HttpEntity responseEntity = new BufferedHttpEntity(response.getEntity());

// Call that garbage collect 30+ times the first exectution
ArrayList<MyObject> responseCollection = mapper.readValue(responseEntity.getContent(), new TypeReference<ArrayList<MyObject>>(){});

return responseCollection;
}

LogCat Output

07-10 11:05:13.484: D/dalvikvm(5518): GC_CONCURRENT freed 497K, 5% free 14030K/14727K, paused 3ms+4ms
07-10 11:05:13.484: D/dalvikvm(5518): GC_CONCURRENT freed 497K, 5% free 14030K/14727K, paused 3ms+4ms
07-10 11:05:13.484: D/dalvikvm(5518): GC_CONCURRENT freed 497K, 5% free 14030K/14727K, paused 3ms+4ms
...
bdon
  • 75
  • 7
  • 1
    The GC on Android is aggressive overall, it doesn't necessarily have anything to do with Jackson. More info here: http://stackoverflow.com/questions/4818869/technical-details-of-android-garbage-collector – Christopher Perry Jul 27 '12 at 22:47
  • @ChristopherPerry So that seems like the answer, please put it in and close :) – Warpzit Aug 15 '12 at 09:20

1 Answers1

0

The GC on Android is aggressive overall, it doesn't necessarily have anything to do with Jackson. More info here:

Technical details of Android Garbage Collector

Community
  • 1
  • 1
Christopher Perry
  • 38,891
  • 43
  • 145
  • 187