malloc/new allocate twice as much?

Dan Stratila dstrat@MIT.EDU
Fri Dec 30 23:30:00 GMT 2005


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. 

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: mem-test.cpp
URL: <>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cygcheck.out
Type: application/octet-stream
Size: 17791 bytes
Desc: not available
URL: <>
-------------- next part --------------
Unsubscribe info:
Problem reports:

More information about the Cygwin mailing list