He can, and usually he does.
On Windows (more specifically on VC ++), the call chain looks like
operator new calls malloc calls HeapAlloc
HeapAlloc is a Windows API function for allocating memory from a specific heap. when the process goes up, it allocates a heap (a CRT heap) in which all the standard distribution takes memory.
No, it is not necessary to call malloc. library developers / end-user developers to decide where they want from their memory.
For example, I can create a single-threaded program. typically, the heap dispenser locks the heap lock during allocation / deallocation to prevent the fatal race condition on the heap. but if my program is monotested, I have no problem.
I can create my own heap using WinApi HeapCreate and pass HEAP_NO_SERIALIZE , which is why the heap skips locking. then I can use operator new with a simple HeapAlloc . this is the case when I can get new to work with another function and then malloc .
Another low-level approach that sometimes runs * is to allocate a huge block of memory using VirtualAlloc , and then pass the recalculated memory address anytime someone calls new .
(all of these actions are performed quite rarely, and from my experience they bring minimal improvement in execution time)
David Haim
source share