This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

malloc/new allocate twice as much?


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

Attachment: mem-test.cpp
Description: Text document

Attachment: 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/

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]