Skip to content

Output Regions Need Explicit Free Method When Assuming Ownership of Naked Realm Instances #1906

@Jacobfaib

Description

@Jacobfaib

Is your feature request related to a problem? Please describe.

I am giving Realm access to some memory I have allocated. I want to be able to tell Realm how to delete this memory later on when it is no longer needed. Currently, I need to separately track when the memory is no longer used (somehow) and call the deleter myself.

Describe the solution you'd like

Realm knows best when to delete the memory I have given it. It should know how to do that. I would like to pass a std::function<void(void*)> to Realm::ExternalMemoryResource.

For example:

auto* memory = my_special_cuda_malloc(size_bytes, ...);

auto resource = Realm::ExternalMemoryResource{
  /* mem */ memory, 
  /* size */ size_bytes, 
  /* deleter */ &my_special_cuda_free
};

Describe alternatives you've considered

Manually tracking the memory lifetime myself and deleting it. This is very cumbersome and bugprone.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions