Skip to content
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

Quick question: is it possible to override the allocator to use something like mimalloc and jemalloc? #5

Open
Trung0246 opened this issue Jun 7, 2023 · 2 comments
Assignees
Labels
documentation Improvements or additions to documentation helpdesk Helping folks use the library / answer questions about the library.

Comments

@Trung0246
Copy link

Trung0246 commented Jun 7, 2023

As title said. However I'm not even sure if it possible yet. Unless I missed something in the documentation.

@ThePhD
Copy link
Contributor

ThePhD commented Jul 19, 2023

The way to change how allocation is done internally in the library is to provide your own heap. The heap portion is not fully documented, but it's part of the function signature: https://ztdcuneicode.readthedocs.io/en/latest/api/heap.html

This will cause the entire API in cuneicode to use specifically that heap. You can fill in the functions from mimalloc and jemalloc to do this by making those functions and create the heap structure, then passing it into the cnc_registry_open function: https://ztdcuneicode.readthedocs.io/en/latest/api/registry.html#_CPPv417cnc_registry_openPP23cnc_conversion_registryP19cnc_conversion_heap20cnc_registry_options

If you notice any allocations not going through the heap, do let me know. In general, the entire API was designed to NOT allocate whatsoever, so if it starts allocating that means there's a problem somewhere.

@ThePhD
Copy link
Contributor

ThePhD commented Jul 19, 2023

If you mean "how do I stop allocation for the regular functions that aren't related to the registry", the answer is "they never allocate, ever, so it's a moot question".

Some of the convenience functions might allocate, but in that case I'd make them take a heap. The convenience functions are not here yet, however, because they require statement expressions and using those in a high-warning-level environment like I do is such a pain that I have not gotten them off the ground yet.

@ThePhD ThePhD self-assigned this Jul 19, 2023
@ThePhD ThePhD added documentation Improvements or additions to documentation helpdesk Helping folks use the library / answer questions about the library. labels Jul 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation helpdesk Helping folks use the library / answer questions about the library.
Projects
None yet
Development

No branches or pull requests

2 participants