The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: ecube on February 01, 2007, 05:22:01 AM

Title: More efficient memory managment?
Post by: ecube on February 01, 2007, 05:22:01 AM
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?
Title: Re: More efficient memory managment?
Post by: zooba on February 01, 2007, 07:46:40 AM
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
Title: Re: More efficient memory managment?
Post by: ecube on February 01, 2007, 04:24:04 PM
Thankyou for the information zooba, it's much appreciated.