Hello,
I try to allocate approx. 50MB of memory for a DIB:
hDIB= GlobalAlloc(GHND,dw /*approx 50MB*/);
It fails. But Windows task manager told me that more than 500MB available.
The OS is win xp.
Why??? What is the problem?
Please help.
br
Ralf
Printable View
Hello,
I try to allocate approx. 50MB of memory for a DIB:
hDIB= GlobalAlloc(GHND,dw /*approx 50MB*/);
It fails. But Windows task manager told me that more than 500MB available.
The OS is win xp.
Why??? What is the problem?
Please help.
br
Ralf
This needs to allocate a contiguous block of 50MB. This may not be available, though many smaller blocks may be available that together make up more than 500MB.
Maybe you could try preallocating the large block of memory early in your program. Or you could try enabling the low-fragmentation heap if you are running on XP.
Hello,
that sounds complicated.
My problem occurs in a DLL.
Do I have to enable the low-fragmentation heap at the beginning of the calling app?
br
ralf
It's not that complicated, but you should do it early in your application (.exe).
See the (second) example for HeapSetInformation.
Just an aside note:
Generally, for the question "Why Xyz (Windows API) function fails?", GetLastError can give a more valuable answer than Task Manager. ;)
Have a look at: How to get the reason for a failure of a SDK function?