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..

Recommended Answers

> here my program crashes.............may be its bcoz the heap memory is less
yes. to specify a larger process default heap size for your executable image, use the /HEAP linker switch. http://msdn2.microsoft.com/en-us/library/f90ybzkh.aspx
to allocate 468 MB of memory, the heap is not …

Jump to Post

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?

Jump to Post

All 6 Replies

Thank you..... i will try out ...........

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?

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?

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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.