I have a program that parses through hundreds of thousands of files, stores data from each file and towards the end, prints some of the data extracted into an excel document.
These are some of the errors I encountered and handled in regards to memory:
java.lang.OutOfMemoryError: Java heap space Increased memory to 2gb
Error occurred during initialization of VM. Could not reserve enough space for 2097152KB object heap downloaded jre8 for 64 bit machine. set -d64 as one of the default vm arguments
java.lang.OurOfMemoryError: GC overhead limit exceeded Increased java heap memory from 2gb to 3g and included this argument -XX:-UseGCOverheadLimit
So now my default VM arguments are: -d64 -Xmx3g -XX:-UseGCOverheadLimit
The issue is that my program runs for several hours, reads in and stores all of the information I need from all of these files and then throws an error at the end when it's trying to print everything if a memory error occurs.
What I'm wondering is if there is a way to store the data extracted and then access it again even if the program exits due to an error. The way I want to store the data is in the same format I use it in the program. For instance, let's say I have several hundred thousand files of user records and I traversed through all of them, stored the data I extracted in user objects and I have these user and other personally defined objects stored in HashMaps and LinkedLists. Is there a way to store these user objects and HashMaps and LinkedLists in a way that even if the program exits due to an error I can write another program that will go through the objects stored so far and printing out the information that I want without having to go through the process of reading in, extracting and storing the information over again?