I have such situation: I read lines from CSV-file and put them to List<String>
. After finishing, lines are parsed according to special logic and their parts are put as keys into several HashMap<String, Integer>
. Then list records is cleared. Actually I tried several ways:
records.clear();
records = null;
records = new ArrayList<String>();
But it seems that memory is not released anyway (checked it by using profiler and simple print to console). Due to such iteration with reading of file and further parsing is repeated several times, at one moment I get an OutOfMemoryError
.
Could anybody suggest any solution here? Is it possible with Java to solve it out? Or pool of string is not negligible for Garbage Collector? Maybe other languages like C++ are more suitable?
Thank you.