-
Notifications
You must be signed in to change notification settings - Fork 842
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
How can mimalloc manage a piece of allocated memory? #922
Comments
Yes, mimalloc has bool mi_manage_os_memory(void* start, size_t size, bool is_committed, bool is_large, bool is_zero, int numa_node); This will add the memory area to the mimalloc arena's from which it will allocate its memory (use Hope this helps, ps. There is also an extended api, |
Thanks very much for your help! It really does me a favor. mimalloc is very useful, and my project cannot be done without it. |
@daanx I am a bit confused about how the mimalloc uses the process memory initially. As far as I know, when the process starts, it already reserves some memory area for the heap, and libc uses sbrk to extend. But I can track mimalloc down, I understand that it does mmap do manage the memory, right? Also, what is the alignment-requirement for the mimalloc? |
Ah, mimalloc generally does not use |
thank you for the clarification! |
I have already allocated a piece of big memory by
mmap
, the memory size (asMEM_SIZE
) is large, so I want to use it as a memory pool, or a heap, so that I can use the memory efficiently. For example, every time I want a piece of memory (large but not larger thanMEM_SIZE
), I can just easily use a function to allocate and get avoid *
, and release this pointer later, and the pool/heap can collect this memory. An example:And if there exists any memory allocator or memory pool library for C++ that can work as above, it is appreciated if you could tell me and leave some examples or the documents of it.
The text was updated successfully, but these errors were encountered: