Trey Howard wrote:
I've noticed that if I paste large amounts of text (100k+ characters)
into a JTextArea that the JVM's performance takes a significant hit.
Has anyone else encountered this and is there is any workaround/solution?
I have also encountered this loss of performance. I believe that the cause is that the
JTextArea tries to convert the entire text string to a bit map for rapid scrolling.
Needless to say, the memory required for the bit map is much larger than the memory
required for the string itself. As the length of the string gets very long, your computer
begins to run out of memory, your virtual memory system begins to thrash, and performance
goes south.
No known workaround nor solution. Long term, what we need is a new class, sub-classed to
JTextArea, that converts only the portion of text that is being displayed to a bit map.
But this class will not provide the smooth scrolling of JTextArea.
Jim Hurt
|