java - JTextArea consumes a lot of memory -
i having memory issue java , swing. have jtextarea
(same issue jtextpane
) use redirect stdout c++ executable. , because i'm outputting lot of stdout, jtextpane
consuming lot of space. in case, boiled down following code, in java.
private javax.swing.jtextarea jtextareastdout; .... (int = 0; < 200000; i++) { string randomstr = uuid.randomuuid().tostring(); jtextareastdout.settext(randomstr); //<tag_memory> if (i % 100 == 0) system.gc(); //<tag_no_help> }
the above code consumes 100mb. tag_memory line commented out, lot less (30mb other code & ui). how can reduce java's memory usage? using java 7 update 4.
thanks in advance.
i don't understand memory going.
plaindocument
tells story: either 1 or 2 16-bit code units per code point, map of line starts , impedimenta needed make editable. read-only viewing, i'd use redirection: yourprogram 2>&1 > view
. in java, read stdin
list<string>
, 1 string
per line, , view jtable
. default renderer quite efficient. there's related example here.
Comments
Post a Comment