Details about allocation

There is an informative post about how Julia’s garbage collection works.

How does Julia 1.7’s memory allocation work?

Everything in that post is still accurate.

1 Like

I should’ve been more specific. The earlier question is about garbage collection, ie how memory gets freed. In this question I’m asking about how memory gets allocated. These are of course related but I think there are some independent elements.

I have read there are a bunch of different allocation strategies, e.g. bump allocator, linked-list allocator, slab allocator, etc. Does Julia’s fall cleanly under one of them? Or does julia just outsource this job to the OS?

I might be wrong, but I think Julia just calls malloc and friends.

The docs go a bit further into it.
https://docs.julialang.org/en/v1/devdocs/object/
Specifically

Memory is allocated from a pool for smaller objects, or directly with malloc() for large objects.

Malloc is used to get memory in large amounts from the OS but Julia does it’s own management within that. There are pools for various small object sizes (rounded up to the next pool size) and a general region for large objects. I believe these are all bump allocators, but I could be wrong about that.

3 Likes