I noticed this weird effect where memory is not registered as allocated by the Windows Task Manager until it is touched instead of when it is malloc
-ed or new
-ed. The effect occurs in both the debug
and optimized release
builds.
The following is a structural example, although in my code the allocation and utilization occurs on different threads so I don't think its the optimizer, although I am not sure how to check.
for (int i = 0 ;i < 1000;i++)
{
buffer[i]=malloc(buffersize);
}
_sleep(1000*60)
for (int i=0;i<1000;i++)
{
memset(buffer[i],0,buffersize);//Only shows up the in the resource manager here
}
My question is how does Windows know I have used the memory? Is it monitoring memory for first usage or is it some compile time optimization.
My curiosity is motivated by a realtime acquisition I am writing that requires me to touch the memory twice -> once when allocating and once when actually filling it with data. Thus pressing a button ("aquire!") requires me to write 64 gigabytes of ram at once, as opposed to over time, adding a fairly real amount of latency. If I malloc
as I go this adds too much latency.
--edit--
I also disabled the Windows pagefile...