[Paraview] memory leak in writer

Natalie Happenhofer nataliehapp at hotmail.com
Fri Jul 17 07:53:19 EDT 2009


Hi!
I´ve written a Wrapper for the Legacy VTK files writer, so that it writes a whole timeseries if I want it to. Lamentably, applying it, it needs more and more memory, so I am looking for a memory leak. 

Here is the bit of code I suspect:

 vtkInformation* inInfo = inputVector[0]->GetInformationObject(0);
  vtkDataObject* input = inInfo->Get(vtkDataObject::DATA_OBJECT());

  vtkSmartPointer<vtkDataObject> inputCopy;
  inputCopy.TakeReference(input->NewInstance());
  inputCopy->ShallowCopy(input);

  vtksys_ios::ostringstream fname;
  if (this->WriteAllTimeSteps)
    {
    vtkstd::string path =
      vtksys::SystemTools::GetFilenamePath(this->FileName);
    vtkstd::string fnamenoext =
      vtksys::SystemTools::GetFilenameWithoutLastExtension(this->FileName);
    vtkstd::string ext =
      vtksys::SystemTools::GetFilenameLastExtension(this->FileName);
    if((this -> CurrentTimeIndex) < 10)  fname << path << "/" << fnamenoext << ".000" <<this->CurrentTimeIndex << ext;
    else if((this -> CurrentTimeIndex) < 100) fname << path << "/" << fnamenoext << ".00" << this -> CurrentTimeIndex << ext;
    else if((this -> CurrentTimeIndex) < 1000) fname << path << "/" << fnamenoext << ".0" << this -> CurrentTimeIndex << ext;
    else fname << path << "/" << fnamenoext << this -> CurrentTimeIndex << ext;
    }
  else
    {
    fname << this->FileName;
    }

//Here I call the usual VTK Writer and set the input

  vtkGenericDataObjectWriter* Writer = vtkGenericDataObjectWriter::New();
  Writer -> SetInput(inputCopy);
  Writer -> SetFileName(fname.str().c_str());
  if((this -> FileType) == 1) Writer -> SetFileTypeToASCII();
  else   Writer -> SetFileTypeToBinary();

  Writer -> Update();

  if (this->WriteAllTimeSteps)
    {
    this->CurrentTimeIndex++;
    if (this->CurrentTimeIndex == this->NumberOfTimeSteps)
      {
      // Tell the pipeline to stop looping.
      request->Remove(vtkStreamingDemandDrivenPipeline::CONTINUE_EXECUTING());
      this->CurrentTimeIndex = 0;
      }
    }

  Writer -> Delete();
  return 1;

Is there anything I forget to delete?


thx for answers
Natalie



_________________________________________________________________
Prueba los mejores juegos online en MSN
http://juegos.latam.msn.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.paraview.org/pipermail/paraview/attachments/20090717/ce767204/attachment.htm>


More information about the ParaView mailing list