3 ms·
Any reading recommendations for introduction to the fundamentals of manual memory management specifically? I tried learning C in the past but didn’t get very fa
by nkrisc 2y ago
Any reading recommendations for introduction to the fundamentals of manual memory management specifically? I tried learning C in the past but didn’t get very far without a compelling need to learn it.
I’ve toyed with Odin a bit and the language in syntax is right up my alley, but the idea of manually managing memory is pretty foreign to me. I understand it broadly, but have no good idea about how to actually do it practically and properly.
I will give this book a look as well since I see it covers the topic in some chapters.
- FullGarden_S 2y ago>Any reading recommendations for introduction to the fundamentals of manual memory management specifically here is a series written by the creator of Odin programming language about memory allocation https://www.gingerbill.org/series/memory-allocation-strategies/ https://www.gingerbill.org/series/memory-allocation-strategi... The core:mem package in standard library is a very great resource for memory management in Odin. The standard library's basically got it all.
- nkrisc 2y agoThank you, I’d missed that!
- amjoshuamichael 2y agoOdin has a builtin heap allocator that works the same way you would expect any other high-level language to do memory allocation–it's just that you have to free the memory yourself. Plus, Odin's built in `context` system makes it really easy to change what kind of allocator is used for different sections of code. For my use cases, I've never needed any more than a heap and an arena, detailed in this talk: https://www.youtube.com/watch?v=nZNd5FjSquk https://www.youtube.com/watch?v=nZNd5FjSquk Personally, my large Odin project uses a series of arrays to store specific data, and then everything else is stored in a temporary allocator, which is wiped between frames. Besides some graphics initialization & path resolution at initialization time, the heap allocator is never used. I never really have to worry about memory. That's similar to the design detailed in this talk by Ryan Fluery: https://www.youtube.com/watch?v=TZ5a3gCCZYo https://www.youtube.com/watch?v=TZ5a3gCCZYo Odin also has a tracking allocator which can be used to check for leaks or double frees. In debug mode, my program will print out all un-freed memory left after shutdown. If you're working outside of Odin, I've heard good things about Valgrind for C/C++: https://valgrind.org/ https://valgrind.org/