Julia's garbage collection of ccall allocated data

Viewed 196

I was hoping someone could clarify one aspect of the behaviour of the Julia garbage collector and how it interacts with memory allocated by a call to a C function using ccall.

For example, I am making the following call:

    setup::Ptr{Void} = ccall(("vDSP_DCT_CreateSetup", libacc), Ptr{Void},
                         (Ptr{Void}, UInt64, UInt64),
                         previous, length, dct_type)

This function allocates memory and initializes memory for a DFT_Setup object (the details of this are irrelevant). The library also provides a destructor to be called on the DFT_Setup to deallocate memory once the object is no longer needed.

Is calling the destructor necessary in Julia? i.e. Does the garbage collector handle freeing DFT_Setup when it is appropriate, or should I make a call to the C deallocator?

1 Answers
Related