[vtkusers] vtkImageColorViewer

Lic. José M. Rodriguez Bacallao jmrbcu at gmail.com
Mon Nov 30 11:31:15 EST 2009


sorry, I forgot to put it in the example, but, I already do what U
said and nothing happened

r = vtkgdcm.vtkGDCMImageReader()
r.SetFileName('/path/to/image.dcm')
r.Update()

v = vtkgdcm.vtkImageColorViewer()
v.SetInputConnection(r.GetOutputPort())
v.SetupInteractor(QT Interactor)
v.SetRenderWindow(Qt Interactor.GetRenderWindow())
v.Render()

this is what I am doing in the close event of my widget in the tab:

v.SetupInteractor(None)
v.SetInputConnection(None)
v = None
del v

r = None
del r


On 11/30/09, David Gobbi <david.gobbi at gmail.com> wrote:
> Hi José,
>
> Please keep the discussion on the list.
>
> In the example code in your email, you aren't disconnecting the viewer
> from the pipeline.  In my email, I specifically said you should remove
> the input from the viewer.  Why didn't you do it?  Don't you like my
> advice?
>
> I will repeat myself.  Before you delete the viewer, do this:
>
> v.SetInputConnection(None)
>
> Email me back and tell me if that works.
>
>     David
>
>
> On Mon, Nov 30, 2009 at 9:02 AM, Lic. José M. Rodriguez Bacallao
> <jmrbcu at gmail.com> wrote:
>> this is how I setup my pipeline:
>>
>> r = vtkgdcm.vtkGDCMImageReader()
>> r.SetFileName('/path/to/image.dcm')
>> r.Update()
>>
>> v = vtkgdcm.vtkImageColorViewer()
>> v.SetInputConnection(r.GetOutputPort())
>> v.SetupInteractor(QT Interactor)
>> v.SetRenderWindow(Qt Interactor.GetRenderWindow())
>> v.Render()
>>
>> this is what I am doing in the close event of my widget in the tab:
>>
>> v.SetupInteractor(None)
>> v = None
>> del v
>>
>> r = None
>> del r
>>
>> but it doesn't release its memory, just a few Mb, not all.
>>
>> On 11/28/09, David Gobbi <david.gobbi at gmail.com> wrote:
>>> Hi José,
>>>
>>> Before calling "del" you should remove it from the pipeline.  This is
>>> done with any one of these three calls:
>>>
>>> object.RemoveAllInputs(), if the object is a vtkAlgorithm
>>>
>>> object.SetInputConnection(None), if the object is faking a vtkAlgorithm
>>>
>>> object.SetInput(None), if the object still uses the old pipeline API
>>>
>>> After that, the "del" should release the memory immediately.  If it
>>> doesn't, you can always force the garbage collection:
>>>
>>> # force python garbage collection
>>> import gc
>>> gc.collect()
>>>
>>> # force VTK garbage collection
>>> import vtk
>>> vtk.vtkGarbageCollector.Collect()
>>>
>>> Forcing the garbage collector usually isn't necessary if you have
>>> disconnected the object from the pipeline.
>>>
>>> Cheers,
>>>
>>>     David
>>>
>>>
>>>
>>>
>>> On Sat, Nov 28, 2009 at 3:50 PM, Lic. José M. Rodriguez Bacallao
>>> <jmrbcu at gmail.com> wrote:
>>>> hi folks, how do I release the memory occupied by an
>>>> vtkImageColorViewer used  from python?
>>>> I think it is not properly garbage collected, even when I try remove
>>>> it with "del"
>>>>
>>>> --
>>>> Lic. José M. Rodriguez Bacallao
>>>> Centro de Biofisica Medica
>>>> -----------------------------------------------------------------
>>>> Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos lo
>>>> mismo.
>>>>
>>>> Recuerda: El arca de Noe fue construida por aficionados, el titanic
>>>> por profesionales
>>>> -----------------------------------------------------------------
>>>
>>
>>
>> --
>> Lic. José M. Rodriguez Bacallao
>> Centro de Biofisica Medica
>> -----------------------------------------------------------------
>> Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos lo
>> mismo.
>>
>> Recuerda: El arca de Noe fue construida por aficionados, el titanic
>> por profesionales
>> -----------------------------------------------------------------
>>
>


-- 
Lic. José M. Rodriguez Bacallao
Centro de Biofisica Medica
-----------------------------------------------------------------
Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos lo mismo.

Recuerda: El arca de Noe fue construida por aficionados, el titanic
por profesionales
-----------------------------------------------------------------



More information about the vtkusers mailing list