JProfiler memory views -> Object size
Asked Answered
D

1

6

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.

Discontinuance answered 21/2, 2013 at 13:47 Comment(0)
M
6

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.

Magnetism answered 21/2, 2013 at 20:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.