954,549 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

clearing JTextArea doesn't free any memory

Hi everyone!

I have written a server client that receives information, does a database transaction and then sends the result back to the client.

My client has requested that they be able to view what was received and what was sent in real time. I have used a JTextArea. The problem came in when I was doing some stress testing on the app. As soon as the number of requests hit about 150k, I noticed that it was using a lot of RAM. I wrote a method to clear the text area (setText(null) and tried setText("")). When the button was pressed that clears the textarea, it clears perfectly, but it was still using a ridiculous amount of RAM, and carried on growing straight away.

The 4 clients were told to send 100k requests each. Stress testing was just to see what would happen as a what if sort of thing.

Anyone have any idea how to use less memory with the JTextarea after it has cleared?

Any help would be appreciated!

Connavar3
Newbie Poster
6 posts since Aug 2010
Reputation Points: 10
Solved Threads: 0
 

I seriously doubt whether the amount of memory used has anything to do with the amount of text you show in your textarea.

stultuske
Posting Sensei
3,137 posts since Jan 2007
Reputation Points: 1,114
Solved Threads: 433
 

Ditto. Maybe you're creating something for each connection or transaction and failing to null all the references to it/them (eg adding them to a List that's not cleared).

JamesCherrill
Posting Genius
Moderator
6,373 posts since Apr 2008
Reputation Points: 2,130
Solved Threads: 1,073
 

Thanks for the help! You were right, I keep track of all of the transactions in a Map, and after they were handled, I forgot to remove them. After I got rid of this, my server uses 300 MB of RAM, instead of shooting up to 800 and crashing.

Thanks!!! :D

Connavar3
Newbie Poster
6 posts since Aug 2010
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: