<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Apr 21, 2016 at 2:48 PM, Sean McBride <span dir="ltr"><<a href="mailto:sean@rogue-research.com" target="_blank">sean@rogue-research.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi all,<br>
<br>
vtkBuffer::Reallocate() has this comment:<br>
<br>
// OS X's realloc does not free memory if the new block is smaller. This<br>
// is a very serious problem and causes huge amount of memory to be<br>
// wasted. Do not use realloc on the Mac.<br>
<br>
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.<br>
<br>
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.<br>
<br>
This patch removes it, all tests still pass:<br>
<<a href="https://gitlab.kitware.com/vtk/vtk/merge_requests/1448" rel="noreferrer" target="_blank">https://gitlab.kitware.com/vtk/vtk/merge_requests/1448</a>><br>
<br>
Any objections?<br></blockquote><div><br></div><div>I agree. My guess is that this code was added to ensure that Squeeze() reclaims memory. If so, then vtkGenericDataArray::Squeeze() is the method that should have been tweaked, rather than vtkBuffer::Reallocate().</div><div><br></div><div> - David</div><div><br></div><div><br></div><div><br></div><div> </div></div></div></div>