Object store object destructor/cleanup callback

How severe does this issue affect your experience of using Ray?

  • Medium: It contributes to significant difficulty to complete my task, but I can work around it.

Would it be possible to have a __del__ type of callback for when an object on the object store gets freed ?
From my understanding, put(x) serializes x and saves it in the object store and when the object_refs get garbage collected, the memory is simply freed and no destructor is called.
This would be really useful in the case where an object in the object store holds the last reference to a resource on a GPU/accelerator (sort of like the object store also frees object_refs nested in serialized objects it holds).

I have tried using wearkref.finalize on an object_ref but it is not supported.
I guess another solution would be to have a callback on the python garbage collector that checks if the object is still in the store but this would add periodic overhead.

Thanks for helping

Hi @wylley, do you mind filing an feature request Github issue with a concrete use case?