Hi. (And thanks for this great site) Im working with some structures, that are linked together as a linked list. Is it "ok" to use GlobalAlloc/GlobalFree as the only mem-management, when i create linked list with more than 1 mill. linked structures. Or should i allocate a larger chunk of mem (like 1 Mb chunks), and then handle allocation/freeing of structs in each chunk? TIA Fragster
I think the docs say it perfectly:
The GlobalAlloc and LocalAlloc functions are limited to a combined total of 65,536 handles for GMEM_MOVEABLE and LMEM_MOVEABLE memory per process. This limitation does not apply to GMEM_FIXED or LMEM_FIXED memory.:D Mirno
statement from newest SDK:
This topic provides a brief comparison of the following memory allocation methods: CoTaskMemAlloc GlobalAlloc HeapAlloc LocalAlloc malloc new VirtualAlloc The following functions are equivalent: GlobalAlloc, LocalAlloc, and HeapAlloc with the handle returned by the GetProcessHeap function. The VirtualAlloc function allows you to specify additional options for memory allocation. However, its allocations use a page granularity, so using VirtualAlloc can result in higher memory usage. The malloc function has the disadvantage of being run-time dependent. The new operator has the disadvantage of being compiler dependant and language dependant. The CoTaskMemAlloc function has the advantage of working well in either C, C++, or Visual Basic. It is also the only way to share memory in a COM-based application, since MIDL uses CoTaskMemAlloc and CoTaskMemFree to marshal memory.