I ran a heap dump on my program. When I opened it in the memory analyzer tool, I found that the java.lang.ref.Finalizer
for org.logicalcobwebs.proxool.ProxyStatement
was taking up a lot of memory. Why is this so?
Some classes implement the Object.finalize()
method. Objects which override this method need to called by a background thread call finalizer, and they can't be cleaned up until this happens. If these tasks are short and you don't discard many of these it all works well. However if you are creating lots of these objects and/or their finalizers take a long time, the queue of objects to be finalized builds up. It is possible for this queue to use up all the memory.
The solution is
The last option is likely to be best for you as you are using an existing library.