[vtkusers] growing RAM memory
Shashwath T.R.
trshash at gmail.com
Sun May 22 14:44:29 EDT 2011
One more suggestion: you don't really need to recreate the renderer every
time. What I usually do is keep the renderer around, and call
RemoveAllViewProps() on it to remove all existing actors, and add new ones.
In fact, very often, I find myself just replacing the input to various
mappers, while keeping the renderer, render window, and even the actors and
mappers intact. This usually keeps things sane for me.
The way memory management works is that if you have other objects that hold
onto the object being deleted, only the reference count is reduced, and the
memory isn't freed up. When you call SetInput(...) on a mapper, for example,
there is a reference created between the data object you set as input, and
the mapper. If you haven't deleted the data object, it'll hold onto the
mapper, even though you've called Delete(), or for that matter, used a smart
pointer, which is a scoped pointer that calls Delete() on the object when it
leaves scope.
Most often, memory problems of this type come from the readers or other
pipeline stages that you've forgotten to clean up when replacing your
pipeline. Try checking for any other objects that you set as input, or
vtkProperty instances that you've created and set to the actors, or
something of that kind. I think your problem isn't at the renderer stage.
Shash
On Sun, May 22, 2011 at 4:33 PM, G G <greenlander1986 at gmail.com> wrote:
> When I use
>
> ren = NULL;
> ren = vtkSmartPointer<vtkRenderer>::New();
>
> ren->SetBackground(1,1,1);
> ren->AddActor(actor);
> widget->GetRenderWindow()->AddRenderer(ren);
>
> it works but, memory is grown again.
>
> when I use
>
> ren->Delete();
> ren = vtkSmartPointer<vtkRenderer>::New();
>
> ren->SetBackground(1,1,1);
> ren->AddActor(actor);
> widget->GetRenderWindow()->AddRenderer(ren);
>
> it doesnt work.
>
> I am desperate. :(
>
>
> 2011/5/22 G G <greenlander1986 at gmail.com>
>
>> I am trying now. In VTK examples Examples\GUI\Qt\Events is in global scope
>> only vtkRenderer... I have tried according this, but it crash in
>> cout<<"bla"<<endl;
>> ren = NULL;
>>
>> ren->SetBackground(1,1,1);
>> ren->AddActor(actor);
>> widget->GetRenderWindow()->AddRenderer(ren);
>> cout<<"ups"<<endl;
>> "bla" is written, but "ups" not. I have in all important method
>> vtkSmartPointer<vtkRenderer> ren
>>
>> inicialization I do only ones, it is problem?
>>
>>
>>
>> 2011/5/21 G G <greenlander1986 at gmail.com>
>>
>>> Thank you, I try it. And post here solution
>>>
>>> 2011/5/21 chasank <chasank at gmail.com>
>>>
>>>> My suggestion is,
>>>> if you do not need more than one renderer and RenderWindow
>>>> - Define them in a global scope,
>>>> - And before each call to the widgetInicialization method, set them to
>>>> the
>>>> NULL
>>>> - in widgetInicialization method, Re-create them, set the values
>>>> - Lastly update your widget object.
>>>>
>>>> --
>>>> View this message in context:
>>>> http://vtk.1045678.n5.nabble.com/growing-RAM-memory-tp4346305p4415624.html
>>>> Sent from the VTK - Users mailing list archive at Nabble.com.
>>>> _______________________________________________
>>>> Powered by www.kitware.com
>>>>
>>>> Visit other Kitware open-source projects at
>>>> 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
>>>>
>>>> Follow this link to subscribe/unsubscribe:
>>>> http://www.vtk.org/mailman/listinfo/vtkusers
>>>>
>>>
>>>
>>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> 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
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20110523/e78fab5e/attachment.htm>
More information about the vtkusers
mailing list