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
intended use of extent hooks #1031
Comments
|
The alloc hook is invoked whenever the arena needs additional memory from the OS, e.g. when all local mapped memory are in use, and we need more memory to satisfy the current request (which is typical done through mmap). The hooks are also used when an arena need memory for internal metadata, e.g. |
|
Closing for now. Please feel free to let us know if any questions. |
|
Thanks a lot for your answer. I think it makes more sense now. Additionally when is the rest of the hooks are called? Is there somewhere documentation about that? I 'm particularly interested in what happens when the dalloc hook is called. All the tests I 've done so far, have not seen it being called for my newly created arena. |
|
Depending on the configuration (i.e. opt.retain is true), dalloc might never get called; in that case we'll save address space for later rather than explicitly deallocate it. |
|
Following up with the original question, is there any documentation about when the rest of the hooks are called? I'm also interested in this, and can't find any documentation (so far). |
|
The best place for documentation is http://jemalloc.net/jemalloc.3.html#arena.i.extent_hooks Regarding the exact locations where the hooks are called, it would be tricky to document since: 1) it depends on options used (e.g. purge vs dalloc); and 2) internally jemalloc may utilize the hooks for metadata (e.g. may call alloc when a new thread comes in). It's also related to internal design, such as splitting a large extent vs allocating a new one, when both can satisfy an allocation request. |
I want to use jemalloc to manage memory within a programming model runtime system, I think in a similar fashion to what is mentioned in #825, however I have some questions regarding how are the extent hooks meant to be used.
My understanding was/is that the extent_alloc_t hook is used to provide memory for a new arena. Subsequent allocation calls from this arena will return memory from the address range that the extent_alloc_t hook will provide. Is that true?
I was experimenting with the interface and I saw that subsequent attempts to allocate memory from a newly created arena using mallocx() invokes the extent_alloc_t hook again.
The scenario I want to work with would be something is along the lines of:
Running this gives me:
The allocation hook is invoked when the arena is getting created (twice).
The first two allocations use the initial allocation of my allocation hook. The next allocation invokes the allocation hook again.
My question hence is: when exactly is each allocation hook invoked? I 've looked both in the documentation and the github issues, but was not able to find something, however, if I missed it please direct me to it.
Thanks in advance.
The text was updated successfully, but these errors were encountered: