Private Memory Allocation
Memory allocation functions in Windows can serve various purposes, and the choice of which on to use depends on your specific requirements and programming context.
Note: The process of allocating private memory using functions like: VirtualAlloc/VirtualAllocEx & VirtualProject/VirtualProtectEx are heavily monitored WinAPI functions.
Malloc and new (C and C++):
These are standard memory allocation function in C and C++. Use them for general-purpose allocation when working with non-Windows specific code.
HeapAlloc:
Use HeapAlloc when you want to allocate memory in a private heap that is associated with a specific process.
LocalAlloc:
Use LocalAlloc for allocating memory that is specific to the current processes and is not intended for sharing across multiple processes.
VitualAlloc:
Use VirtualAlloc when you need to allocate memory and also specific characteristics. Such as reserving space, commiting memory pages, or definining privileges
NtAllocateVirtualMemory:
NtAllocateVirtualMemory is the NTAPI equivalant to VirtualAlloc. It offers a lower level of abstraction and more granular control over memory allocation.
CoTaskMemAlloc:
Use this function when you need to allocate memory for COM (Component Object Model) objects or data that will be shared across COM interfaces.
GlobalAlloc:
Use this function to allocate memory that can be accessed accross multiple processes. NOTE: This approach is outdated, and modern Windows programming tends to avoid it.
Last updated