flat assembler
Message board for the users of flat assembler.

Index > Windows > Best API for memory allocation?

Goto page Previous  1, 2
Author
Thread Post new topic Reply to topic
itsnobody



Joined: 01 Feb 2008
Posts: 93
Location: Silver Spring, MD
itsnobody 15 Feb 2008, 01:43
LocalAlloc took around 11 seconds, but my computer seemed to slow down, HeapAlloc took around 10 seconds
Post 15 Feb 2008, 01:43
View user's profile Send private message Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3175
Location: Denmark
f0dder 15 Feb 2008, 02:34
Definitely stick with HeapAlloc for smaller allocations, forget all about Local/GlobalAlloc rubbish, and consider VirtualAlloc if you need huge (several megabytes) allocations, or need the specific alignment/protection stuff VirtualAlloc has to offer.

Oh, there's a very few uses for Local/GlobalAlloc though, iirc the clipboard APIs require it, and CreateStreamOnHGlobal... because when not allocating "FIXED" or "GPTR", even though l/galloc use HeapAlloc internally, they add some extra control structure, and you can end up with corrupted heap structures if you don't play by the rules.
Post 15 Feb 2008, 02:34
View user's profile Send private message Reply with quote
unfadedcolor



Joined: 12 Feb 2008
Posts: 2
unfadedcolor 15 Feb 2008, 05:39
i will be quite clear after you figure out what difference between heap and stack.
Post 15 Feb 2008, 05:39
View user's profile Send private message Reply with quote
kandamun



Joined: 20 Jul 2005
Posts: 25
kandamun 15 Feb 2008, 15:47
My wild wild guess is that HeapAlloc receives by its heap handle s.th. without effort, something that GlobalAlloc needs to look up or create on every call.
Post 15 Feb 2008, 15:47
View user's profile Send private message ICQ Number Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3175
Location: Denmark
f0dder 15 Feb 2008, 15:51
kandamun: stop making wild guesses, and disassemble kernel32.{Local,Global}Alloc Smile
Post 15 Feb 2008, 15:51
View user's profile Send private message Reply with quote
kandamun



Joined: 20 Jul 2005
Posts: 25
kandamun 15 Feb 2008, 16:05
No, i'm too lazy and i have my own bugs to disassemble Smile
Post 15 Feb 2008, 16:05
View user's profile Send private message ICQ Number Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.