new[] doesn't decrease available memory until populated
问题 This is in C++ on CentOS 64bit using G++ 4.1.2. We're writing a test application to load up the memory usage on a system by n Gigabytes. The idea being that the overall system load gets monitored through SNMP etc. So this is just a way of exercising the monitoring. What we've seen however is that simply doing: char* p = new char[1000000000]; doesn't affect the memory used as shown in either top or free -m The memory allocation only seems to become "real" once the memory is written to: memcpy