Thread with 3 posts
jump to expanded postare there any memory allocators that support partial freeing? suppose i’m doing a character encoding conversion and i cheaply estimate the amount of space required. after conversion i’ll find out maybe as much as half of the space isn’t actually needed. what if i could tell the allocator i don’t need it, so it can re-use it if possible, without moving the rest of my allocation?
I’m sure some implementations of realloc() do this but…
@hikari not the answer you were looking for but pypy does this with its moving GC. When you realloc a young string buffer to be smaller, it leaves a hole in the nursery after it. When it eventually gets moved to old generation, it gets put into a smaller memory slot