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).
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 can only be enabled for one type (class) at a time.