Garbage collector in Android is running, but nothing is shown as being allocated in ddms' allocation tracker

后端 未结 2 588
说谎
说谎 2020-12-19 18:41

In my application, I\'m careful not to make heap allocations in the main render loop, to prevent the garbage collector from having to do its thing.

After making a se

相关标签:
2条回答
  • 2020-12-19 19:04

    Please provide info about the kind of garbage colletor. Bitmap allocation, meaning the actual bitmap pixels(not bitmap information which is very small) is allocated into the heap, BUT not visible to any allocation tracker tool for android version below 3.0 (Honeycomp). So if you are loading bitmap information GC extrernal allocation will be called.

    0 讨论(0)
  • 2020-12-19 19:15

    (I had already found the solution but am posting the question+answer for other's benefit)

    As it turns out, I was able to track the problem down to calling the .values() method of a enum class, which allocates a new array on every call. But for some reason, those allocations don't show up in ddms's allocation tracker, so it makes it rather difficult to track down.

    Luckily, I was able to use git bisect to find the specific change that introduced the issue, and then tracked it down to the exact problem in that change.

    Edit: After some additional testing, it seems that cloning an array in general doesn't show up in the allocation tracker.

    Additional Info: This seems to be an issue in Honeycomb and below, when cloning an object. It will be fixed in ICS. (http://code.google.com/p/android/issues/detail?id=19831)

    0 讨论(0)
提交回复
热议问题