I am wondering if it is possible to create a finalise method for OCaml records? I am creating a GPU database and I am using OCaml for building the DSL to query and manipulate GPU data, and I need a way to free GPU memory when they are eligible for GC (not referenced anymore).
I have creating a binding to my C-based GPU api to allow to malloc, free and manipulate GPU data but I am looking at solutions to free GPU memory when it is not referenced by variables anymore in the toplevel.
let bids = (**a 1-dim GPU array*) and asks = (**another 1-dim GPU array*) in
let spread = asks - bids
In this example, I would need to free up the GPU memory for the bids and asks vector residing in GPU memory. I guess I need to write my own language?