I am studying WINAPI programming and doing bit kind of experiments by writing winapi codes. When I moved toward 'Memory Management using winapi' topic, I saw there are some 'Memory Manipulation Mechanisms' which is
Virtual Memory
> LPVOID VirtualAlloc(
LPVOID lpAddress,
SIZE_T dwSize,
DWORD flAllocationType,
DWORD flProtect);
Memory Mapped Files
> HANDLE CreateFileMappingA(
HANDLE hFile,
LPSECURITY_ATTRIBUTES lpFileMappingAttributes,
DWORD flProtect,
DWORD dwMaximumSizeHigh,
DWORD dwMaximumSizeLow,
LPCSTR lpName
);
Heaps
> HANDLE HeapCreate(
DWORD flOptions,
SIZE_T dwInitialSize,
SIZE_T dwMaximumSize
);
But I unable to understand that, when to use Virtual memory and when to use Heaps mechanism similarly for memory mapped files. what is the real time example for using any of this, or in programmers point of view in which scenario i have to prefer virtual memory,mapped files,heap ?.