News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

More efficient memory managment?

Started by ecube, February 01, 2007, 05:22:01 AM

Previous topic - Next topic

ecube

is it more efficient to have various LOCAL bufname[1024]:BYTE's in a procedure that's called a great deal or to use GlobalAlloc/GlobalFree?

zooba

Locals. They are a simple subtract command (sub esp, <total size>) which is probably happening anyway.

Next best option is to allocate the buffer once and keep passing the same pointer in, though this will make the procedure non re-entrant.

Finally, the speed differences between Global* functions and Heap* functions are (IIRC) minimal, but the Heap* functions are recommended by Microsoft so I'd opt for those over Global* basically every time.

Quote from: MSDNNote  The global functions are slower than other memory management functions and do not provide as many features. Therefore, new applications should use the heap functions. However, the global functions are still used with DDE, the clipboard functions, and OLE data objects.

Cheers,

Zooba :U

ecube

Thankyou for the information zooba, it's much appreciated.