[vtkusers] Memory leak
Jothybasu Selvaraj
jothybasu at gmail.com
Tue May 15 10:51:30 EDT 2012
Thanks for both!
Fixed it finally.
Jothy
On Tue, May 15, 2012 at 3:30 PM, Hal Canary <hal at cs.unc.edu> wrote:
> On 05/15/2012 10:19 AM, Jothybasu Selvaraj wrote:
>
>> Hi all,
>>
>> I have a pipeline like this, every time I call this function the memory
>> increases ~10MB. How can I fix this?
>>
>> I have a imgData already instantiated like this
>>
>> vtkSmartPointer<vtkImageData>**img=
>> vtkSmartPointer<vtkImageData>:**:New();
>>
>> vtkSmartPointer<**vtkXMLImageReader>rd=
>> vtkSmartPointer<**vtkXMLImageReader>::New();
>> rd->SetFilename("filename");
>> rd->Update();
>>
>> img=rd->GetOutput();
>>
>>
>> //Now I repeat this function several times
>>
>> vtkSmartPointer<**vtkImageShiftScale>scaler=
>> vtkSmartPointer<**vtkImageShiftScale>::New();
>> scaler->SetInput(img);*//is this correct way of doing?*
>>
>>
>> scaler->SetScale(0.5);//**Multiply
>> scaler->**SetOutputScalarTypeToDouble();
>>
>> //scaler->ReleaseDataFlagOn();**//Tried with this too
>> scaler->Update();
>>
>> img=scaler->GetOutput();*//is this correct way of doing?*
>>
>>
>> I am beginner in C++, so I am expecting some silly mistakes.
>>
>>
> Nine out of ten times , you want to do
> b->SetInputConnection(a->**GetOutputPort());
> instead of
> b->SetInput(a->GetOutput());
>
> See http://www.vtk.org/Wiki/VTK/**FAQ <http://www.vtk.org/Wiki/VTK/FAQ> .
>
> Is this what you want to do?
>
>
> vtkSmartPointer<**vtkXMLImageReader>rd=
> vtkSmartPointer<**vtkXMLImageReader>::New();
> rd->SetFilename("filename");
> rd->Update();
> vtkAlgorithmOutput * outputPort = rd->GetOutputPort();
>
>
> //Now I repeat this function several times
> {
> vtkSmartPointer<**vtkImageShiftScale>scaler=
> vtkSmartPointer<**vtkImageShiftScale>::New();
> scaler->SetInputConnection(**outputPort);
>
> scaler->SetScale(0.5);//**Multiply
> scaler->**SetOutputScalarTypeToDouble();
> scaler->Update();
> outputPort = scaler->GetOutputPort();
> }
>
> //then
> do_something_with(outputPort);
>
>
> --
> Hal Canary
> http://cs.unc.edu/~hal/
> ______________________________**_________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/**
> opensource/opensource.html<http://www.kitware.com/opensource/opensource.html>
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_**FAQ <http://www.vtk.org/Wiki/VTK_FAQ>
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/**listinfo/vtkusers<http://www.vtk.org/mailman/listinfo/vtkusers>
>
--
Jothy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20120515/b0654e98/attachment.htm>
More information about the vtkusers
mailing list