flat assembler
Message board for the users of flat assembler.
Index
> Windows > Memory allocation problem |
Author |
|
madmatt 16 Sep 2006, 09:36
You could use the functions in 'crtdll.dll', 'alloc, realloc, free', just don't forget to use 'cinvoke' for each of them.
perimeter's required for the above mentioned functions: malloc memsize realloc memblock, newsize free memblock |
|||
16 Sep 2006, 09:36 |
|
vid 16 Sep 2006, 10:08
GetProcessHeap / HeapAlloc / HeapRealloc / HeapFree
|
|||
16 Sep 2006, 10:08 |
|
RedGhost 16 Sep 2006, 22:47
You can use the Heap or Virtual functions, or the crtdll functions which are just wrappers for the former.
_________________ redghost.ca |
|||
16 Sep 2006, 22:47 |
|
ManOfSteel 17 Sep 2006, 07:30
Hello,
the functions of crtdll.dll you are talking about, are they the same as GlobalAlloc, GlobalLock, GlobalReAlloc, etc... What is the difference between these Global* Functions and the Heap functions? |
|||
17 Sep 2006, 07:30 |
|
okasvi 17 Sep 2006, 09:53
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/memory/base/memory_management_functions.asp
copy&pasted from msdn: Quote: The following are the global and local functions. These 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 and the clipboard functions. |
|||
17 Sep 2006, 09:53 |
|
madmatt 17 Sep 2006, 13:29
The global functions are a bit more involved to use, you have to: allocate, lock, USE, unlock, free. Virtual***** functions the same way, also many more parameters. For simple memory uses the CRT functions are the way to go. However, if you need more advanced control and protection over your memory then use the Virtual***** functions.
|
|||
17 Sep 2006, 13:29 |
|
vid 18 Sep 2006, 07:57
yup, for simple malloc(), realloc(), free() use Heap* functions
|
|||
18 Sep 2006, 07:57 |
|
ManOfSteel 19 Sep 2006, 13:12
okasvi,
Quote: These functions are slower than other memory management functions and do not provide as many features. The program could work on three files containing more than 8.400 words, that it processed one by one, letter by letter, in less than one second with an old 333MHz celeron. And I still have not optimized any code for speed. So speed-wise, I think it is more than satisfying. I do not really need many features (if any). All I need is to allocate some memory for words, keep the words there for a few milliseconds, process them, write them to a file and free all the memory. That's it. madmatt, Quote: The global functions are a bit more involved to use, you have to: allocate, lock, USE, unlock, free. Basically, allocate, USE and free are enough. AFAIK, lock/unlock pair is not necessary if you use fixed memory chunks (GMEM_FIXED) since doing so will directly return a pointer to the allocated memory instead of a handle. It works perfectly like that, so far. The USE part is not very cycle-consuming, since you can do it with two mov instructions (one to get the address of the pointer and one to read/write from/to the address) and when using heap or crt functions you still have to read from and/or write to your re/allocated memory, don't you? And is it normal that a c library like crtdll.dll be faster than a system DLL like kernel32.dll? I always hear c libraries are slow, unoptimized and sometimes even buggy. |
|||
19 Sep 2006, 13:12 |
|
madmatt 19 Sep 2006, 16:35
I haven't done any speed tests, so I don't know which is faster. Maybe you could do some tests and post the results? As far as the c library (crtdll.dll) being buggy, I've used the [malloc, free] functions on occasion and haven't had any problems yet.
|
|||
19 Sep 2006, 16:35 |
|
vid 19 Sep 2006, 20:47
see this: http://f0dder.schwump.net/memalloc.htm
|
|||
19 Sep 2006, 20:47 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.