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!

Recommended Answers

All 3 Replies

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

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).

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.