Reputation: 1
I have a simple question. I have a program that requires writing a large amount of memory from a file into a vector, so everytime it starts it takes about a minute or so to write in all the memory into the vector. My question is, is there any way to maybe have that "writing in" process takes place once and for all and use the memorized vector for when running the program in the future?
Upvotes: 0
Views: 14
Reputation: 16364
General answer: No. Once a program quits, the OS will reclaim all the memory it was using.
However, there are some alternatives you might consider:
If you call the program repeatedly, you could restructure it so that the program keeps running, and you just execute commands within the program. (Or, being a bit more fancy: The main program runs as a daemon, and you launch another program that just passes a new job to the daemon and then echoes the result)
If you are doing a lot of work parsing the file, you could write a new file containing the data exactly as it is laid out in memory, so that you can load it with a single read operation.
Upvotes: 1