Avatar of harishalwala
Flag for Afghanistan asked on

JTextpane consumes more memory

I am using a swing application that use multiple JTextpanes that contains huge Text & background painting. When I open one after the other textpane from the tabs, it cosumes around 100M, but once I close the tab with textpane, the memory remains and doesnot release to GC.
Any solution please.

Avatar of undefined
Last Comment

8/22/2022 - Mon

After you no longer need JTextPane (after you close it), assign its variable to null - perhaps it will be garbage collected sooner.
You can even call garbage collecition after that your self with System.gc() - although it is usually not recommended

How do you know it does not realease memory?
It deoes not do it immediately - only after GC runs -  so you need to check after some time

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.