Hi, This is an issue I've discovered and reproduced while trying to compile polymake (see the thread "gcc crash (memory?)"). It seems that both malloc and new allocate take up twice the amount of memory needed.
I wrote a short program to allocate and use memory in chunks (mem-test.cpp), and compiled it with g++ 3.4.4. I monitored it using the Windows Task Manager. When asked to allocate 100MB in increments of 10MB, the process size goes to 100MB and then drops to 0, as expected. However, the total commit charge for the machine goes up by 200MB, and then drops back! One might think it's a harmless bug in Task Manager, but the problem is that the total commit limit for the machine is 2GB, and I ask mem-test for 1.1GB of memory, then it is unable to obtain the last 100-200MB (and Windows complains about low memory as well). The problem seems to occur with both malloc and new. The same program compiled with MS Visual C++ behaves normally. I am able to get 1.1GB, and both the process size, and the total commit charge are as expected. I have reproduced this bug on another machine, also running Windows XP SP2, with a fresh Cygwin install. The cygwin.out for my machine is the same as for the "gcc crash (memory?)" thread, but I re-attach it in any case. Sincerely, Dan
/* $Name: $ $Id: mem-test.cpp,v 1.3 2005/12/30 23:09:55 dstrat Exp $ mem-test tests how much RAM an application can get. Usage: mem-test <# chunks> <chunk size in MB>. */ #include <iostream> #include <cstdlib> using namespace std; int main(int, char* argv[]) { int *p, i, iMax=0, j, k, numChunks, chunkSize; numChunks=atoi(argv[1]); chunkSize=atoi(argv[2]); cout << "mem-test: numChunks=" << numChunks << ", chunkSize=" << chunkSize << "." << endl; cout << "mem-test: Allocating: " << flush; for (i=0;i<numChunks;i++) { cout << i+1 << flush; p=new int [chunkSize*1024*1024/4]; if (p) { cout << "+" << flush; iMax=i+1; for (k=0;k<8;k++) for (j=0;j<chunkSize*1024*1024/4;j++) p[j]=k+j; cout << "d " << flush; } else cout << "!" << flush; } cout << "\nmem-test: Done." << endl; cout << "mem-test: Successfully allocated " << iMax*chunkSize << "MB, in " << iMax << " chunks of " << chunkSize << "MB each." << endl; return 0; } // End.
cygcheck.out
Description: Binary data
-- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/