I wrote a program that requires ~1GB of RAM zeroed at startup, and this is taking more time than the rest of the program combined from a cold start. (it’s a simple program, subsequent runs take almost no time at all to allocate). When watched via task manager, it starts with almost no RAM, and then grows about 2MB/sec until it reaches the 1GB it needs. I found options “Heap Reserve Size” and “Heap Commit Size”, and set them to 1000000000 each, but when I watched the program via task manager, the program appears to start at 1GB, and then grow at that 2MB/sec until I get a bad_alloc. The line in question is:
std::vector<std::vector<char> > data(512, std::vector<byte>(2097252, 0));
Can someone clearly explain what these options are for, and if there is a way to use them to speed my allocations? I have read http://msdn.microsoft.com/en-us/library/f90ybzkh(v=vs.80).aspx, but it doesn’t explain the behavior I observed.
I wrote a program that requires ~1GB of RAM zeroed at startup, and this
Share
I realized it’s probably because the first run has to page stuff out of RAM to the hard drive, whereas the subsequent run has all that unused RAM left behind after the first run. The allocation/zeroing has nothing to do with it. Sorry all.