Hi, 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?
If I read your post right you want a way to allocate memory and remain allocated so that when you re-open the program it will read that memory rather than read from the disk and re-populate the Vector?
Memory allocated is temporary and should be deallocated when the program exits otherwise you would have a memory leak. Furthermore, switching off the computer would clear the ram anyway.
If this data is simply lookup data and never changes then you could create a header file with the said data - the result of this would be a increased exe file size but would be a lot faster.
say, I create a header file with the data, wouldn't I still need to write in the vector? Or, how exactly do you mean by creating a header file with said data? Sorry, I'm pretty new to C++.
Most of the time taken to populate your vector is the access times of your hard disk, memory works at such high speed.
Without knowing what kind of data we are talking about here I will assume for this example it is a list of 100 postcodes (or zip codes depending where you are)...
1 2 3 4 5 6 7 8 9 10
string postcodes[100] = {
"dh7oa",
"ne991bb",
// and so on..
};
Again, this is not suitable if the data changes at runtime, but if its just lookup data that never changes it would be a solution. Also remember that this would increase your exe file size.