FAQ
Most frequent questions
- What is a memory leak?
- Why are those error messages I get "cannot enhance..."?
- How can I know where my leaks are?
- Why is my process slow with JLeak?
- How does JLeak work?
- What is a memory leak?
- Basically, a memory leak occurs when an object is created within a program but never deleted. Unlike in C++, there is no destructor you can call to free an object, the garbage collector is here to perform this task. However, the GC will only do its job when no more reference is held on an object. If, for instance, you create an object that you add within an array that is never deleted, this object will not be deleted either since the array holds a reference on it. This may or may not be a real problem, actually. It depends on whether other objects are created during the application lifecycle, which will be added over the time within the array. If yes, the application will consume more an more memory during its life, until no more is available. There comes JLeak to help you detect leaking objects.
- Why are those error messages I get "cannot enhance..."?
- For a very few classes, such as those created on the fly by middlewares such as hibernate, JLeak is not able to instrument the code in order to detect instantiation and destruction from the garbage collector. For those, an error message is displayed in the console since there is nothing else we can do.
- How can I know where my leaks are?
- When you see the number of instances of a given class growing continuously over the time, without reducing significantly when invoking the GC, you probably have a memory leak. Then, select the associated checkbox and start recording. Then, by double clicking on the given line, you will get another dialog box showing all the instances: select one and you will get the instantiation stack trace.
- Why is my process slow with JLeak?
- JLeak adds dynamically some code that is executed by your application, in a quite significant amount: it takes more time, and more memory by the way.
- How does JLeak work?
- JLeak uses "javassist", a library used by hibernate which is able to modify classes' bytecode on the fly, without needing to know how bytecode works. As such, JLeak adds some code in all the constructor found in each class, and add a finalize method. Those then invoke a manager that increment and decrement the number of instance for each class. This kind of bytecode enhancement can only be done once, when the class is loaded by the JVM at its very first instantiation. This is one of the abilities a java agent has: it can perform whatever bytecode modification before the JVM starts using the class.

Contact us