Reputation: 806
When I profile app's memory in Android Studio I can see consumption of different categories of memory,
but when I dump Java heap (middle button), I get only allocations of heap,
which was expected from button's name. But still I can see allocated char arrays and Strings so far, but as we know in recent versions char arrays from String are moved to native heap and String class has access to them only via native methods, so it turns out that this heap dump shows also Native heap. Am I right? What about graphics heap?
Upvotes: 4
Views: 5545
Reputation: 21733
While it's not an authoritative source by any means, myself and others tried to explain java memory use here. As far as I am aware (somebody who works with ART or Davlik can give you a much more definite answer) there is only a single heap available to your entire application, no specific graphics heap.
What Android Studio is probably showing you is how much of the heap is being consumed by graphics operations. Similar to how the Stack (green) memory segment is showing you what the current call stack is consuming. You can view how this is reflected in your code by highlighting a segment:
When you are using this view you should remember to select your application heap from the dropdown:
Native & Java segments show you how much memory was allocated directly through the SDK/Java frameworks and how much natively through the underlying structures. (They don't show you different memory areas within your app, it can seem confusing - see the link at the end)
The best overview of what exactly the profiler is showing you is in the Developer Documentation which also outlines what System Image and zygote heaps are to you as well.
Upvotes: 4