From 617b8668c73acba773c8bf74e7525b3263853a9d Mon Sep 17 00:00:00 2001 From: ayenpure Date: Fri, 20 Apr 2018 13:48:54 -0700 Subject: [PATCH] Fixing memory leak in Streamlines Fixing memory leak introduced bacause of increamenting the num of steps in the wrong place while generating streamlines --- vtkm/worklet/particleadvection/Particles.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/vtkm/worklet/particleadvection/Particles.h b/vtkm/worklet/particleadvection/Particles.h index e58a98839..58cb80b18 100644 --- a/vtkm/worklet/particleadvection/Particles.h +++ b/vtkm/worklet/particleadvection/Particles.h @@ -239,10 +239,9 @@ public: { // Irrespective of what the advected status of the particle is, // we need to set the output position as the last step taken by - // the particle, and increase the number of steps take by 1. + // the particle. Pos.Set(idx, pt); vtkm::Id nSteps = Steps.Get(idx); - Steps.Set(idx, ++nSteps); // Update the step for streamline storing portals. // This includes updating the history and the valid points. @@ -250,6 +249,9 @@ public: History.Set(loc, pt); ValidPoint.Set(loc, 1); + // Increase the number of steps take by 1. + Steps.Set(idx, ++nSteps); + // Check if the particle has completed the maximum steps required. // If yes, set it to teminated. if (nSteps == MaxSteps)