Hi,
I am sorry if I put this in the wrong topic, but I am not really sure exactly where to put this issue.
So, a while back, I had asked (here) how to have my
Java 1.6 program write updates into a JTextArea while it was executing processes, and I was pointed to SwingWorker. Here is a link to my previous topic . . .
https://coderanch.com/t/567777/GUI/java/show-new-text-JTextArea-while
And since then I have modified my code so that it now uses a SwingWorker to do all of the non-Swing tasks in a background
thread. The SwingWorker reads a text file, searches for specific data, then does some processes on that data and then displays the results in HTML browsers. The files that the program will have to read are text, and they vary in size, 1KB - 900MB, but typically, the files range 1MB-100MB.
Here is my issue. The program works fine with any file size when I exectue it from Netbeans (in fact it is quite fast). However, if I execute the program outside of Netbeans, then on the LARGE files (>200MB), if fails to complete the processing. I do not get any errors of any type other that ones that I wrote into the code to let me know what happened. I also have the program do some logging, and I can see that the problem always occurs AFTER the program has read in ~200MB from a file.
The way the program works is it ... 1) Sets up a GUI 2) A user selects a file to process 3) Then the program creates a SwingWorker (background) thread and reads the file, does the processing, and then done() will write out the results.
Here is code that I have in the program that does the reading ...
The reason I that I have it process after it has read 4K is for performance. That is, the program will read, and process 4K at a time. And then after it has read and processed all the 4K bundles, it puts all back into an ArrayList so that it can be all printed out.
So, I am still a greenhorn (obviously) and I am lost as to how to resolve this problem. As the program works just fine in Netbeans, I am thinking that my issue is possibly . . .
- A memory management issue? That is, Netbeans is doing some memory management so that the program works when it is executing there.
and/or
- Is the issue maybe because I am using StringBuilder?
Thanks in advance!