What is the difference, practically speaking, between using Malloc, HeapAlloc, & VirtualAlloc (advantages/disadvantages)? Also, is it better to use the program's heap or to initiate a private heap? It seems HeapAlloc has the potential for fragmentation issues, & VirtualAlloc may be slow due to garbage collection. I need to allocate memory blocks anywhere from a 4 bytes to hundreds of thousands of bytes with the lengths of the arrays changing as the program runs. Any suggestions? Thanks.
Take a look at the following article: http://f0dder.schwump.net/memalloc.htm
pro3carp3,
With variable size allocations done of the fly from small to large, try the OLE string memory allocation functions. They are used in the two macros in MASM32 alloc$() and free$.
include \MASM32\include\oleaut32.inc
includelib \MASM32\LIB\oleaut32.lib
; -----------------------
alloc$ MACRO ln
invoke SysAllocStringByteLen,0,ln
mov BYTE PTR [eax], 0
EXITM <eax>
ENDM
free$ MACRO strhandle
invoke SysFreeString,strhandle
ENDM