This content has been marked as final. Show 2 replies
The question is: what are 25 MB of text doing in an applet? Who's supposed to look at all that info? Trim down the amount of information you display. You couldn't even navigate through that pile of text.
A datatype that takes up less memory than stringbuffer perhaps?How would that work? If you have 25 MB of data, you'll have 25 MB of data.
I guess your problem comes up when you create a String from the StringBuffer - I don't know if or how StringBuffer and String are sharing their backing arrays, but I'd assume for simplicity's sake they don't. So you end up with a 25 MB String and a 25 MB StringBuffer.
Just a thought but could you not simply append and output the text to the text area of the applet in increments instead of all at once, and then clear the StringBuffer and repeat for the next portion of text from the file? It would probably take longer to display the text due to its massive size but you wouldn't run out of memory for the StringBuffer object itself.