[vtk-developers] vtkBuffer::Reallocate special case for OS X realloc()

Sean McBride sean at rogue-research.com
Thu Apr 21 16:48:07 EDT 2016


Hi all,

vtkBuffer::Reallocate() has this comment:

// OS X's realloc does not free memory if the new block is smaller.  This
// is a very serious problem and causes huge amount of memory to be
// wasted. Do not use realloc on the Mac.

We've been profiling our app and this OS X-only workaround is a major performance killer for a use case involving blending 3D datasets.  We measured a 250% runtime performance improvement of Render() in release builds by getting rid of this special-casing!  Tonnes of time was being spent in malloc and std::copy.

It seems entirely reasonable for realloc() to not automatically recoup the memory if the buffer is made smaller: for all it knows, you'll soon after realloc it bigger again.  Also, for all we know the OS could recoup the memory later.

This patch removes it, all tests still pass:
<https://gitlab.kitware.com/vtk/vtk/merge_requests/1448>

Any objections?

Cheers,

-- 
____________________________________________________________
Sean McBride, B. Eng                 sean at rogue-research.com
Rogue Research                        www.rogue-research.com 
Mac Software Developer              Montréal, Québec, Canada




More information about the vtk-developers mailing list