java - JTextArea ran out of room? How much text can fit, can I fit more than that? -
i working on visualizer pattern found in prime numbers. here link maths stackmath:patterns in primes , full code stackcodereview:optimization of code
my problem seems running out of room in jtextarea.
errors:
exception in thread "main" java.lang.outofmemoryerror: java heap space @ javax.swing.text.gapcontent.allocatearray(unknown source) @ javax.swing.text.gapvector.resize(unknown source) @ javax.swing.text.gapvector.shiftend(unknown source) @ javax.swing.text.gapcontent.shiftend(unknown source) @ javax.swing.text.gapvector.open(unknown source) @ javax.swing.text.gapvector.replace(unknown source) @ javax.swing.text.gapcontent.insertstring(unknown source) @ javax.swing.text.abstractdocument.handleinsertstring(unknown source) @ javax.swing.text.abstractdocument.insertstring(unknown source) @ javax.swing.text.plaindocument.insertstring(unknown source) @ javax.swing.jtextarea.append(unknown source) @ primesandbox.main(primesandbox.java:67)
line 67:
screen.append(arrays.tostring(primesll.toarray()) + "\n");
so thing can figure have text in textarea. can increase size can hold? or must create method save of not shown text string , rewrite when scroll? (i don't want to)
the quick , dirty answer give more heap space:
java -xmx2g primesandbox
← gives 2gb, example
whether long term solution depends on whether need "little bit more", or whether have rampant memory problem.
you won't achieve memory savings moving strings around within application. string displayed in jtextarea
not going more memory intensive string in field in class. writing out disk other option.