What are the Windows and Linux native OS/system calls made from malloc()?

后端 未结 5 1443
生来不讨喜
生来不讨喜 2020-12-31 15:19

I recently saw the following post:

A memory allocator isn\'t lower level than malloc. (The default allocator typically calls malloc directly or indi

5条回答
  •  醉酒成梦
    2020-12-31 15:51

    Alright, I am not sure about Linux, but when it comes to windows...

    Memory can be allocated in two categorized places.

    1) Heaps (Process Heap, Custom Created Heaps) see -> http://msdn.microsoft.com/en-us/library/windows/desktop/aa366711(v=vs.85).aspx using functions like HeapAlloc & HeapFree. LocalAlloc and LocalFree can be used as 'shortcuts' to HeapAlloc when you want to allocate in the default process heap.

    2) Virtual Memory (usually only process-specific due to access restrictions in global virtual memory for security), using VirtualAlloc, VirtualFree. see -> http://msdn.microsoft.com/en-us/library/windows/desktop/aa366916(v=vs.85).aspx

    To my knowledge, malloc will use the heap allocation functions on windows.

    I hope this helps.

提交回复
热议问题