flat assembler
Message board for the users of flat assembler.
Index
> Windows > Question on memory allocation... |
Author |
|
vid 07 Sep 2008, 09:01
You allocate when you don't know the needed size in advance.
|
|||
07 Sep 2008, 09:01 |
|
dacid 07 Sep 2008, 09:16
After a search in the forum and in msdn, i found that HeapAlloc & VirtualAlloc are the best choices to allocate. Seems that HeapAlloc for small allocations and VirtualAlloc for bigger ones.
|
|||
07 Sep 2008, 09:16 |
|
asmcoder 07 Sep 2008, 12:05
[content deleted]
Last edited by asmcoder on 14 Aug 2009, 14:56; edited 1 time in total |
|||
07 Sep 2008, 12:05 |
|
vid 07 Sep 2008, 13:02
Quote: sub esp,xxx - buffer but only if you are sure it won't be too big. Up to few kilobytes, taking more off the stack is not so good idea. |
|||
07 Sep 2008, 13:02 |
|
f0dder 07 Sep 2008, 13:31
HeapAlloc for generic memory allocations, Local/GlobalAlloc for those few APIs that require it (clipboard related, CreateStreamOnHGlobal, etc.). VirtuaAlloc for huge allocations.
Stack is fine for several kilobytes, and preferable to heap because it's much faster to add/sub esp than managing heap structures. Just remember to pre-touch pages to trigger guard-page allocation mechanism |
|||
07 Sep 2008, 13:31 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.