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?
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.
Cheers, D Drmmr
Please put [code][/code] tags around your code to preserve indentation and make it more readable.
As long as man ascribes to himself what is merely a posibility, he will not work for the attainment of it. - P. D. Ouspensky
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?
Bookmarks