0

I did HANDLE hHeap = GetProcessHeap(); which gives me the handle to the heap of the process then i did
DWORD dsize = 468178553;
(near pointer)PBYTE pBuffer = (LPBYTE)HeapAlloc(hHeap, 0, size);
but here i got pBuffer as NULL and then i did
_stprintf( (TCHAR*)pBuffer,"", , ,);
here my program crashes.............may be its bcoz the heap memory is less than
dsize(468178553)................how to solve this.........do i need to use a far pointer(LPBYTE).....plz help..

3
Contributors
6
Replies
8
Views
9 Years
Discussion Span
Last Post by risa
0

DWORD dsize = 468178553;
PBYTE pBuffer=(PBYTE)::VirtualAlloc(NULL,dsize ,MEM_COMMIT,PAGE_READWRITE);

but still its crashing.......i hav 1GB of RAM and my virtual memory settings are:
initial size (1024MB)
Max size(1509MB)
Curently allocated(4044MB)
Wht shld i do?

0

Curently allocated(4044MB)! if you are on a 32-bit machine, the address space is almost exhausted; you certinly won't get another 400 MB+ memory.

are you allocating this memory just once in your program?
if not are you freeing yhe allocated memory (VirtualFree with MEM_RELEASE) after use?

0

What do you mean by 'crashing'?
Is it so that VirtualAlloc returns NULL and you are still using the pBuffer?
Or something else?

0

yes.............virtualalloc() is returning NULL hence when used in pBuffer it crashes...........i want to allocate more than 400MB upto say 1GB.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.