I have a program that is parsing a large file ( ~1 MB )
It parses it into a data structure.
The memory (heap usage) after it is loaded is ~10MB.
I have looked at the code using OptimizeIt and about 5MB of the heap is taken up by allocations to char which, when you trace the allocation, all come from StringBuffer.
At certain parts of the program, I'll read some of the file and do something like
StringBuffer buf = new StringBuffer();
I'll then append() to buf
I would have thought that this allocation would be garbage collected and come out of the heap usage but it doesn't seem to. Is this right?
Running garbage collection with System.gc() makes no difference.
Are these allocations hanging about in the heap?
How do I free the memory?