-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Time to replace current allocator? #53
Comments
Maybe its better to use something on top of malloc, rather tan replacing it. malloc() is a bit special on our platform, because it has to deal with non-contingues allocations from the system. You could maybe take a look at all the g_slice_ etc functions from glib. |
Actually Doug Lea's allocator is not only quite popular but also quite flexible. Assuming that at least something works on our platform. ;) As we don't have mmap / munmap calls, I tried to take the path with
Reading through sbrk implementation also doesn't give me much confidence that the function is really compliant with the spec... |
I guess the culprit could be the zero parameter which is not handled in mintlib (basically passed to |
That is because brk()/sbrk() are nonsense with non-continguous memory blocks, you cannot just increase/decrease it. The current implementation just uses it in places where the original would have called sbrk()to get more memory. And the standard also says |
What about emulating it? Apple does it, we could perhaps too? |
On the other hand, now I get all the shenanigans with |
Look closer. They emulate it by allocating a contingous, virtual area of memory. |
mintlib does basically the same with |
If you are curious: mikrosk@630015c ... it was rather easy but the time to discover how it works, argh. Eero has a good way to profile this allocator's performance so I'm curious how it will go. Also, if we decide to go ahead with this one, we'd get memalign and other (broken/missing) functions as a bonus. |
_heapbase is only set and used when you limit yourself to a fixed size heap. Normally, you don't want to do that, since it either fails if your machine hasn't that much memory available, or fails with out-of-memory when hitting that limit, although the machine has more available. Kind of defeating the purpose of dynamically allocated memory. |
Still, the apple's example is based on the same idea, at least as far as sbrk is concerned. |
See https://www.atari-forum.com/viewtopic.php?p=444500&sid=de5eec694a4cabb1cc3b696227a883dc#p444500
While it's clear that the game / engine must be optimised to avoid that many malloc / free calls, maybe it's still worth considering to replace the allocator with something modern / more flexible?
The text was updated successfully, but these errors were encountered: