8 ms·
malloc is just a C api, it’s not a syscall, and Linux is no different. malloc/free on Linux is probably using mmap under the hood, and doing some bookkeeping to
by qsdf38100 4y ago
malloc is just a C api, it’s not a syscall, and Linux is no different.
malloc/free on Linux is probably using mmap under the hood, and doing some bookkeeping to decide when to decommit memory to give it back to the OS.
- astrange 4y agoWhen did I say anything about syscalls or Linux?
- qsdf38100 4y agoYou said "they invented 15 ways instead of having malloc". By "they" you mean Microsoft right? Windows does have malloc as a C api for programs using the C runtime library. Same as everywhere else. Then, at the OS api level, there are indeed several memory management functions. But you usually don’t need them. Except if you are writing a custom memory allocator for instance. Also same as everywhere else. So saying Windows has X memory management functions instead of malloc is incorrect.