mspapant
mspapant

Reputation: 2050

How to calculate heap fragmenation statistics using heap dumps

Does anyone knows if there is any tool out there to calculate the heap fragmentation using heap dumps?

Upvotes: 0

Views: 327

Answers (2)

Neil Weightman
Neil Weightman

Reputation: 431

The IBM Garbage Collection and Memory Analyzer is excellent for that sort of thing and is free.

Upvotes: 0

bobah
bobah

Reputation: 18864

I have a tool to visualize the heap (http://bobah.net/d4d/tools/cpp-heapmap) but it consumes the list of {op;address;size} triplets, not a raw heap dump. You can use it to visually estimate how bad the heap is. In some cases it's just enough. It's malloc interceptor would obviously not fit for Java app, but the UI does not care where numbers come from and would display ones from any source.

But let's assume we are able build a heap map from the dump (I'm sure someone will answer here how exactly). The main part of the problem is to calculate fragmentation curve F(s), s - target allocation size. F(s) - the ratio of (total_free_space/s), to number of blocks of size s which can actually be allocated considering particular heap layout.

Once the F(s) is built, one can integrate it in the interval from 1 to S (total heap size) to have a single number representing the heap fragmentation or usage efficiency.

Upvotes: 0

Related Questions