Allocation traces

The last major feature in Memleak to be discussed in this book, is the ability to turn on allocation tracing for any given type. To, for instance, find out where the Leak$DemoObjects are being allocated in our previous example, simply right click on the type and then click on Trace Allocations. The example has been tailored to do allocations in the vicinity of the code that causes the actual leak (note that this is normally not the case).

Allocation traces

As can be readily seen from the screenshot, we are invoking put more often than remove. If we are running Memleak from inside Eclipse, we can jump directly to the corresponding line in the Leak class by right clicking on the stack frame and then clicking on Open Method from the context menu.

Allocation traces

Allocation traces can only be enabled for one type (class) at a time.

Note

A word of caution: Enabling allocation traces for types with a high allocation pressure can introduce significant overhead. For example, it is, in general, a very bad idea to enable allocation traces for java.lang.Strings.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.123.34