-
Notifications
You must be signed in to change notification settings - Fork 946
Return usable allocation size on allocation #2
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
Comments
Thanks for the suggestion! Currently, mimalloc provides two functions for this, I think it is better to have these as separate functions to avoid duplicating all allocation API functions. Soon, I'll have the full doxygen docs online that gives an easier overview of the whole API |
Yes, I'm currently using This means that Also, with the One way to solve this is to not expose a |
P0901 provides another view on this issue. It makes IMO a strong case against providing either |
Nice reference, and a good argument. I am worried about how many extra versions of each allocation function we get though; mimalloc is supposed to stay "lean and mean" so I am hesitant on this issue and need to consider it further. |
Completely understand, take your time and gather feedback from others before deciding on this. One way to keep the API lean, is to not provide two versions of each allocation function in the "Extended" API, one returning I don't know how hard it is to make sure that returning two words does not incur a performance impact over just returning one word. AFAICT, as long as the API has to compute the "good size" internally any ways, it shouldn't have an impact, at least on all ABIs that allow for two return registers. On ABIs that do not support this, returning the two words might require passing the |
Any update on this ? |
jemalloc provides
smallocx
(e.g. see implementation here: https://github.com/jemalloc/jemalloc/blob/dev/src/jemalloc.c#L3015), which not only returns a pointer to the allocation, but also the size of the allocation size class (that is , the usable allocation size).It would be nice if for all allocating and resizing operations a similar API could be provided, so that users that might want to use all usable space don't have to query the size class.
The text was updated successfully, but these errors were encountered: