3 ms·
> No, it definately can't. Glibc malloc can return memory to the OS. This is what the trim that people are talking about does.
by chrisseaton 7y ago
> No, it definately can't.
Glibc malloc can return memory to the OS. This is what the trim that people are talking about does.
- scott_s 7y agoI got tripped up on that statement, too. The problem is that tinus_hn's parent comment started with a false premise: that the only way to return memory to the OS is by moving memory around, which is not the case. I think CJefferson was saying that manual memory allocators can't move memory around (which in the general case is true, but you point out in a different thread there are cases when it can), because the rest of their comment is explaining how they can return memory.
- CJefferson 7y agoSorry, I should have been clear I was specifically replying to suggestion that glibc (or any malloc, by which I mean C standard library memory manager) could move memory allocations.
- chrisseaton 7y ago> specifically replying to suggestion that glibc (or any malloc, by which I mean C standard library memory manager) could move memory allocations But I think malloc can move memory allocations - it can move objects out of a page and return it to the kernel by copying objects into an existing page with a gap and then remapping the old addresses onto the copied page. Then the memory has moved but retains the same address and the old page is returned. See for example the Mesh allocator which does this and still manages to expose a conventional malloc interface. https://github.com/plasma-umass/Mesh https://github.com/plasma-umass/Mesh
- CJefferson 7y agoOK, mesh is doing something very cool and unusual. I've never seen that before (in my defense, it is a 2019 academic paper). It still has its limits, as it can only merge allocations which don't overlap modulo 4096.