Arc Forumnew | comments | leaders | submitlogin
2 points by sacado 6132 days ago | link | parent

There is another optional parameter to cdef : a finalization function. This function is called when the object return by the imported function is GCed. That way, you've got C and garbage collection :

  (cdef zeros "zeros" cptr (cint cint) del)
In the above, del is called on objects returned by zeros once they are collected.

The sad thing is that, if memory is allocated on the C side, Arc can't know it. If you define (zeros 5000 5000), you eat 200 MB. You can run out of memory before the GC thinks "Hey, let's clean up !"