The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: The_Grey_Beast on April 29, 2005, 03:00:04 PM

Title: HeapAlloc and VirtualAlloc
Post by: The_Grey_Beast on April 29, 2005, 03:00:04 PM
What is the difference between them (except that VirtualAlloc rounds to page boundaries). Why use VirtualAlloc if HeapAlloc can do the job?

Also, please help me with this: Virtual memory = Physical Memory + Swap Page File (right?).. Is HeapAlloc allocating in the Swap File if there is not enough Physical memory, or does it report an Out of Memory error because there is not enough physical memory? Thanks.  :toothy
Title: Re: HeapAlloc and VirtualAlloc
Post by: hutch-- on April 29, 2005, 03:23:25 PM
I moved this posting to the workshop so that you will get more answers. The MASM32 forum is for MASM32 specific postings.
Title: Re: HeapAlloc and VirtualAlloc
Post by: Eóin on April 29, 2005, 06:08:59 PM
I'm not an expert, but VirtualAlloc is a lowerlevel memory management function, HeapAlloc would be higher level. Basically use HeapAlloc unless you're reserving very large blocks of memory or need the extra control VirtualAlloc provides.
Title: Re: HeapAlloc and VirtualAlloc
Post by: pro3carp3 on April 29, 2005, 06:58:17 PM
There is some good info on memory management here:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/memory/base/memory_management.asp
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/memory/base/memory_management.asp)
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dngenlib/html/heap3.asp
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dngenlib/html/heap3.asp)
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dngenlib/html/msdn_heapmm.asp
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dngenlib/html/msdn_heapmm.asp)
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dngenlib/html/msdn_manamemo.asp
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dngenlib/html/msdn_manamemo.asp)
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dngenlib/html/msdn_virtmm.asp
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dngenlib/html/msdn_virtmm.asp)