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

new feature: provides a way to control memory allocation and deallocation #5365

Open
1 task done
Tracked by #5367
tbEgg opened this issue Nov 28, 2024 · 2 comments
Open
1 task done
Tracked by #5367
Labels
enhancement New feature or request

Comments

@tbEgg
Copy link

tbEgg commented Nov 28, 2024

Feature Description

OpenDAL currently does not support allowing callers to take control of memory management, which is crucial for programs based on C and C++.

Problem and Solution

Enable users to define a custom memory allocator that can replace the default Rust memory allocation mechanisms.

Additional Context

No response

Are you willing to contribute to the development of this feature?

  • Yes, I am willing to contribute to the development of this feature.
@tbEgg tbEgg added the enhancement New feature or request label Nov 28, 2024
@Xuanwo
Copy link
Member

Xuanwo commented Nov 28, 2024

cc @PragmaTwice @xyjixyjixyji @silver-ymz, is it possible to pass an Allocator from the C side? I haven't seen such an attempt before; perhaps we are the pioneers in this area. It should be exciting.

@xyjixyjixyji
Copy link
Contributor

xyjixyjixyji commented Nov 28, 2024

I think it is possible, we pass 2/3 pointers (malloc, free, option<realloc>) to the rust side, and rust side set it as the global allocator. (api will look like opendal_set_malloc())

But user has to guarantee that if this is expected it should be called before any opendal internal function that might have dynamic memory allocation.

Another way would be we only expose several industry standard allocator directly as interfaces, such as opendal_set_use_jemalloc().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants