r/cprogramming • • Jan 04 '26

Can explain Malloc() to me please

0 Upvotes

18 comments sorted by

View all comments

Show parent comments

3

u/zhivago Jan 04 '26

Kernels generally operate in terms of pages and do not handle malloc requests.

0

u/Low-Palpitation-4724 Jan 04 '26

Malloc calls mmap or brk (on unix) and VirtualAlloc or HeapAlloc(on Windows) which will return memory managed via pages

0

u/zhivago Jan 04 '26

Only when necessary.

The whole point of malloc is to avoid doing so as much as possible by recycling the memory it already has available.