[vtk-developers] zero-copy mixed language support in vtkDataArray

Burlen Loring burlen.loring at gmail.com
Fri Jan 17 15:37:56 EST 2014

Hi All,

I'd like to request a change to vtkDataArray that will extend/improve 
support for zero-copy with mixed language programming. The change would 
add a method similar to SetArray that takes a callback function which 
will be invoked when VTK is done with data. This makes zero-copy 
ownership possible when free/delete [] aren't the right choice for 
releasing the memory.

The use case I'm targeting is zero-copy from Numpy ndarray data. In my 
python-c++ glue code I can increment the PyArray's ref count ensuring 
the data that VTK is given is not released while VTK needs it. VTK 
invokes the callback which decrements the PyArray's ref count when the 
data is no longer needed, which allows the data to safely be released. 
Another use case that the callback would addresses is support for 
zero-copy from FORTRAN where heap based arrays are created with 
FORTRAN's "allocate" function and need to be destroyed with its 
"deallocate" function. I investigated the use of a functor rather than 
function pointer, however the "C" function pointer will be the easiest 
to use in the mixed language setting.

I'm interested to here peoples thoughts on this change. if there are no 
objections to the concept/approach, would anyone be willing to review?


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtk-developers/attachments/20140117/f44d05b1/attachment.html>

More information about the vtk-developers mailing list