Off-heap memory allocated by DeviceArray objects are freed in the finalizer, i.e., cudaFree(...) is called in the objects finalize() method.
As finalize() is deprecated since Java 9, resource deallocation should be implemented using finalization queues.
The finalizer queue should be checked at certain points throughout the lifetime of the language context and memory buffers on the queue freed up with cudaFree(). The cleanup must be performed by the proper thread. Given grCUDA is registered as single-threaded language in Truffle, the deallocation must be performed by the main thread.
Off-heap memory allocated by
DeviceArrayobjects are freed in the finalizer, i.e.,cudaFree(...)is called in the objectsfinalize()method.As
finalize()is deprecated since Java 9, resource deallocation should be implemented using finalization queues.The finalizer queue should be checked at certain points throughout the lifetime of the language context and memory buffers on the queue freed up with
cudaFree(). The cleanup must be performed by the proper thread. Given grCUDA is registered as single-threaded language in Truffle, the deallocation must be performed by the main thread.