Its a nifty tool, but I can't help feeling a little disappointed that we're still having to deal directly with issues such as memory allocation in 2019.
You don't necessarily. Don't forget that theres memory managed languages that compile to c. They still use malloc under the hood.
Tinyalloc: replacement for malloc/free in unmanaged, linear memory situations
31–40 of 60 posts
Re: Tinyalloc: replacement for malloc/free in unmanaged, linear memory situations
#32Re: Tinyalloc: replacement for malloc/free in unmanaged, linear memory situations
#33Its a nifty tool, but I can't help feeling a little disappointed that we're still having to deal directly with issues such as memory allocation in 2019.
Re: Tinyalloc: replacement for malloc/free in unmanaged, linear memory situations
#34Its a nifty tool, but I can't help feeling a little disappointed that we're still having to deal directly with issues such as memory allocation in 2019.
Re: Tinyalloc: replacement for malloc/free in unmanaged, linear memory situations
#35Something like
memory_manager m(some_buffer);
allocation a = m.allocate(512);
would be nice. :-)[0] https://medium.com/iskakaushik/eli5-jemalloc-e9bd412abd70
Re: Tinyalloc: replacement for malloc/free in unmanaged, linear memory situations
#36Earlier quoted context omitted.
There are other ways to get chunks of memory separate from the stack - static uninitialized byte arrays.
Of course, but then we are back to memory pools.
There are differences of course, but that memory can be used in the same way, and so memory pools are orthogonal to how the memory is aquired.
Re: Tinyalloc: replacement for malloc/free in unmanaged, linear memory situations
#37Earlier quoted context omitted.
There are other ways to get chunks of memory separate from the stack - static uninitialized byte arrays.
Yeah, but it's nicer to define that kind of stuff in your linker script IMO, where sizes of large memory regions can be thought of holistically.
Also if the goal is to get one chunk of memory with a single call, why use malloc at all? Why not use the direct memory mapping command?
Re: Tinyalloc: replacement for malloc/free in unmanaged, linear memory situations
#38Earlier quoted context omitted.
Of course, but then we are back to memory pools.
What is the difference between allocating memory right when the program starts with malloc and using the same size in static unitialized byte arrays? There are differences of course, but that memory can be used in the same way, and so memory pools are orthogonal to how the memory is aquired.
Re: Tinyalloc: replacement for malloc/free in unmanaged, linear memory situations
#39Earlier quoted context omitted.
https://github.com/thi-ng/tinyalloc/blob/master/tinyalloc.c#...
Thanks. In my defense, GitHub search is garbage: https://github.com/thi-ng/tinyalloc/search?q=Heap&unscoped_q...
Re: Tinyalloc: replacement for malloc/free in unmanaged, linear memory situations
#40As some comments point out that this code might not be production ready, can anyone recommend other solutions that are able to manage a given block of memory? My understanding of libraries like jemalloc is that they are replacing malloc (using system calls brk and mmap [0]) but I can't hand it an already allocated block of memory to manage, right? Something like memory_manager m(some_buffer); allocation a = m.allocat…
https://android.googlesource.com/platform/external/qemu/+/em...
https://android.googlesource.com/platform/external/qemu/+/em...
These 3 files should be a fairly self contained, minimal way to allocate into existing buffers. No attempt is made at thread safety though (we assume the user synchronizes that themselves)