Is there any book about memory allocators ?

Coders forum. Discuss techniques, swap code snippets, ask for help etc. relating to all forms of software development.
User avatar
venusian
Baaaaaaa!
Baaaaaaa!
Posts: 6651
Joined: Wed Nov 06, 2002 2:22 pm 0
Location: South Gloucestershire

Re: Is there any book about memory allocators ?

Post by venusian »

We have, I think, decided that the book is useless unless you've written it yourself.
User avatar
GoatFoam
Baaaaa!
Baaaaa!
Posts: 1255
Joined: Tue Dec 12, 2006 11:05 am 0
Location: Brizzle
Contact:

Re: Is there any book about memory allocators ?

Post by GoatFoam »

Dio wrote:The ones you can do with a single atomic substitution are workable, but frankly I'm done with anything else.
Atomic publishing protocol is easy. It's the cleanup afterwards that gets hairy.
User avatar
gilesgoat
Sheepie Whore
Sheepie Whore
Posts: 27258
Joined: Wed Sep 03, 2003 7:54 am 0
Location: Monfalcone, Italy
Contact:

Re: Is there any book about memory allocators ?

Post by gilesgoat »

venusian wrote:We have, I think, decided that the book is useless unless you've written it yourself.
Then when I'll be fully done I should write a PDF paper "About Giles' mem allocator" ?
Giles the billy goat
"Baa"
User avatar
Little stoned kiwi
Baaaaaa!
Baaaaaa!
Posts: 4597
Joined: Mon Oct 27, 2003 6:05 am 0
Location: Christchurch

Re: Is there any book about memory allocators ?

Post by Little stoned kiwi »

Post your self-documenting code to GitHub.
If they think you're crude, go technical; if they think you're technical, go crude. I'm a very technical boy.
User avatar
gilesgoat
Sheepie Whore
Sheepie Whore
Posts: 27258
Joined: Wed Sep 03, 2003 7:54 am 0
Location: Monfalcone, Italy
Contact:

Re: Is there any book about memory allocators ?

Post by gilesgoat »

Little stoned kiwi wrote:Post your self-documenting code to GitHub.
FUCK GITHUB !
Giles the billy goat
"Baa"
User avatar
GoatFoam
Baaaaa!
Baaaaa!
Posts: 1255
Joined: Tue Dec 12, 2006 11:05 am 0
Location: Brizzle
Contact:

Re: Is there any book about memory allocators ?

Post by GoatFoam »

What isn't obvious to me is what the allocator is supposed to be for.

Standard library allocators are hard to beat for general purpose use, and tuning tends to be a matter of improving performance for one set of use cases at the expense of others.

Special purpose allocators are a different matter, but they tend to come with constraints. e.g. you use arena allocators for temporary working sets, slab allocators if you are creating lots of recyclable objects of the same size, free lists if you want to recycle them etc.

Then of course there are other considerations. For example, a simple 2 page compacting garbage collector will work fine with any old arena allocator but if you are sweeping instead then you need to care about fragmentation.

Many of the general purpose allocators tend to be hybrids with structures optimised for different allocation patterns. Any old data structures book will get you the basics but making it work well is all about fine details.

Me? I use the default allocators for about 99% of my code, with custom allocators plugged in very occasionally for special circumstances. Only where the profiler has told me the code needs attention.

C++17 pmr stuff gives a mechanisms to plug allocators into most standard containers, along with a grab bag of the more useful special purpose types.
User avatar
Little stoned kiwi
Baaaaaa!
Baaaaaa!
Posts: 4597
Joined: Mon Oct 27, 2003 6:05 am 0
Location: Christchurch

Re: Is there any book about memory allocators ?

Post by Little stoned kiwi »

gilesgoat wrote: FUCK GITHUB !
But memory allocators you and others submit trains Copilot to help people writing their own memory allocators.
If they think you're crude, go technical; if they think you're technical, go crude. I'm a very technical boy.
User avatar
GoatFoam
Baaaaa!
Baaaaa!
Posts: 1255
Joined: Tue Dec 12, 2006 11:05 am 0
Location: Brizzle
Contact:

Re: Is there any book about memory allocators ?

Post by GoatFoam »

Little stoned kiwi wrote:
gilesgoat wrote: FUCK GITHUB !
But memory allocators you and others submit trains Copilot to help people writing their own memory allocators.
It's true. All the most reliable memory data structure code comes from stackoverflow or copilot.
User avatar
Little stoned kiwi
Baaaaaa!
Baaaaaa!
Posts: 4597
Joined: Mon Oct 27, 2003 6:05 am 0
Location: Christchurch

Re: Is there any book about memory allocators ?

Post by Little stoned kiwi »

Especially stack overflow. Peer reviewed, init?
If they think you're crude, go technical; if they think you're technical, go crude. I'm a very technical boy.
User avatar
Little stoned kiwi
Baaaaaa!
Baaaaaa!
Posts: 4597
Joined: Mon Oct 27, 2003 6:05 am 0
Location: Christchurch

Re: Is there any book about memory allocators ?

Post by Little stoned kiwi »

Part of me wants to use Copilot to write a memory allocator on a public GitHub that I link to asking for contributions and feedback at stack overflow and Reddit.
If they think you're crude, go technical; if they think you're technical, go crude. I'm a very technical boy.
Post Reply