Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JProfiler memory views -> Object size

I have the following classes in my application:

class A {
  String someString;
  Locale someLocale;

  Map<Integer, B> someMap = new HashMap<Integer, B>();

  fillMap() {
    // some logic to fill the map with instances of B
  }
}

class B {
  // lots of filled collections
}

I'm doing a profiling session with JProfiler to identify some memory problems. On the Memory View tab, with Aggregation level Classes, I have for example 2000 instances of A, with a total size of 156KB.

My question would be what this size means? Is it just the size of the references to the A object or also the size of all the filled members of A (I'm wondering especially about the Map)? I guess it's somehow only the A reference size but wanted to make sure of this.

like image 819
Deelazee Avatar asked Feb 21 '13 13:02

Deelazee


1 Answers

The dynamic memory views do not show retained sizes, only shallow sizes.

To see retained sizes, go to the heap walker, double click on the class to create a new object set. Then, click on "Calculate retained and deep size" in the header.

This gets you the retained size for the entire class, although the retained sizes for single instances may be more interesting. For that, go to the "References" view or the "Biggest objects" view.

like image 151
Ingo Kegel Avatar answered Oct 13 '22 00:10

Ingo Kegel