Getting OutOfMemoryError



I am creating JGoView object and putting it into the panel and putting jpanel into JFrame. The canvas size would be approx 5000 * 5000
After disposing JFrame object, the heap memory is not decreasing. I tried creating JFrame and putting JGoView object and disposing it in a for loop of 500. After loop ends,heap memory is not coming down and eventually I am getting OutOfMemoryError.
The code for disposing JFrame


fr.getContentPane().removeAll(); Or fr.removeAll();
The same operation I did without using JGo object but i did not find any memory leakage.
Can you please let me know if JGo internally maintains some object reference may be some listeners registration etc etc and not releasing it. Because ideally, the JGoView object should be available for GC but its not.
Thanks & regards,
Binit Bhaskar


Any explicit way e.g. mehod call to free up the JGO View object so that it can free up the heap memory ?


JGo is no different from any other Java object. You’re really at the mercy of the Java garbage collector. Disposing an object just releases its native resources. You need to make sure than any JGo objects you create ultimately go out of scope or otherwise become unreachable so that they are available for garbage collection.