1
votes

I've been trying to use JConsole to identify whether or not I have a memory leak.

I let my code run for a long time, and ensure it performs many iterations of all functions available, starting/ stopping all threads many times, instantiating and releasing every object many times, encountering as many unexpected conditions/ errors as possible.

After all this, if I press "Perform GC" a few times in Jconsole and the green "Heap" memory graph returns to 0-- does this mean, assuming all code has been executed several times, that I (probably) don't have a memory leak?

Or can memory be leaked elsewhere than the heap?

1

1 Answers

1
votes

I see some possibilities:

  • Not closed connections
  • Maps with keys, which have wrong implemented hashCode/equals method
  • in WebApps: Data kept in sessions
  • clean-up-code doesn't run because of exceptions --> Most of the time, this leaks occur in production, because they need time "to build up", or a special situations: Not available database, ....

Your test is a good sign, however no garantee.