Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JTextArea to emulate a terminal window  RSS feed

Enrique Conway
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greetings all.
I am developing the front end to a system that makes remote calls (via a corba channel) to components to issue commands, and displays the results back to the user in a scrolling JTextArea. Updates are at a freq of about 1-2/seconds. I want the text area to behave like a DOS prompt or a unix terminal window, in that new input will be appended to the tail of the document and the window will autoscroll to the last characters entered. I also have set a maximum document size on the component, and prior to any append() call I check to see if the document needs to be trimmed. If so, I chop off X number of chars from the top of the document, effectively creating a FIFO scrolling window.
All works just fine, but for one problem. Each time there is and append() call, the system memory footprint jumps from 1-5 mb. Eventually, it causes the JVM to abort due to lack of available memory. (System is a Sun Solaris Ultra 10 - crashes when the memory exceeds 2 gb, running JDK1.4.01)
Things I've tried so far to no avail:
1. implemented my own Document by extending PlainDocument and removing some of the event notification, undo/redo support, and extraneous object creation not required by my particular component
2. Called System.gc() after every call to append(), also on the Document's insertString() method
3. Removed auto-scroll call to see if the leak is in the modelToView() call or in creating extraneous creation of Rectangle objects.
BTW - I am making appropriate use of SwingUtilities.invokeLater(Runnable) to handle the CORBA callbacks, and all methods I'm calling are declared threadsafe according to the javadocs.
Any help/suggestions or pointers to pre-build components would be appreciated. Thank you.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!