Writing a Memory Allocator (2019)
dmitrysoshnikov.com
Writing a Memory Allocator (2019)
1–10 of 44 posts
Re: Writing a Memory Allocator (2019)
#2Re: Writing a Memory Allocator (2019)
#3Re: Writing a Memory Allocator (2019)
#4Re: Writing a Memory Allocator (2019)
#5Every time I hear someone talking about writing a memory allocator, it always reminds me of the brilliant CppCon 2015 talk by Andrei Alexandrescu about how he wrote an modular allocator library that can be built up in pieces to make whatever you like. https://www.youtube.com/watch?v=LIb3L4vKZ7U
You can build a jemalloc in about 10 lines roughly.
Re: Writing a Memory Allocator (2019)
#6Re: Writing a Memory Allocator (2019)
#7Re: Writing a Memory Allocator (2019)
#8Implementing a memory allocator seems to require system calls. What happens when there's no OS? For example on an MCU like Arduino, is the memory allocator packaged along with the program data? If so and in the case of an Arduino, is the code for it available anywhere? I would be curious to see how this is implemented on an embedded system.
Re: Writing a Memory Allocator (2019)
#9Implementing a memory allocator seems to require system calls. What happens when there's no OS? For example on an MCU like Arduino, is the memory allocator packaged along with the program data? If so and in the case of an Arduino, is the code for it available anywhere? I would be curious to see how this is implemented on an embedded system.
You generally don’t have dynamic memory allocation on such a system. All memory will either be statically allocated globals, or on the stack. Some systems even require stack allocation to be statically determined, which means no recursion.
Re: Writing a Memory Allocator (2019)
#10I built a memory allocator for testing not too long ago that only allocated but no-op'd deallocate(using the C++ Allocator interface). It was quite amazing that it resulted in a 25-50% performance boost in many cases I was testing. It's not for real code as you only get destruction but not deallocation. It let me pull that part out of the tests to get a better view of the performance