In real applications, how do you know that you have a memory leak

If you profile your application, you can notice a graph like a saw tooth. Here is how you can determine this with the help of jconsole for the above bad key class example. All you have to do is while your MemoryLeak is running, get the Java process id by typing.


5808 Jps

4568 MemoryLeak

3860 Main


Now, open up the jconsole as shown below on a command line


C:\>jconsole 4568