Antonio Bleile wrote:
> Hi Andreas,
> 
> late response, but I just got into it right now:
> 
> Andreas Zieringer wrote:
>> Hi Antonio,
>>
>>> Hi,
>>>
>>> just a quick question, why is this code leaking
>>> memory:
>>>
>>> while( true ){
>>>      beginEditCP(m_pFBO, FBOViewport::CameraFieldMask);
>>>          m_pFBO->setCamera(PerspectiveCamera::create());
>>>      endEditCP(m_pFBO, FBOViewport::CameraFieldMask);
>>> }
>>>
>>> ???

  - please see below -

>>>
>>> Shouldn't the setCamera method destroy implicitly the old
>>> camera set on the viewport (he should hold the last
>>> reference to the old camera!)
>>
>> yes, try this: Thread::getCurrent()->getChangeList()->clearAll();
> 
> It doesn't work as I expect it to work. I attached a modified
> version of the first tutorial. In each render loop it creates
> some osg instances. When you press <esc> it prints a list of
> non deallocated instances. All instances created in the loop
> are still alive. Only calling explicitly subRefCP frees the
> memory. Doing something like:
> 
> PassiveBackgroundPtr pw;
> 
> while( true )
>     pw = PassiveBackground::create();
> 
> leads to memory leaks. Also calling getChangeList()->clearAll()
> doesn't help much. Is this behaviour by design?

yes, <SomeContainer>Ptr is not a reference counting pointer, if you need 
that please use <SomeContainer>RefPtr.
In the example the ref count of all PassiveBackgrounds remains zero all 
the time and is never touched and since destruction only happens when 
the ref count is decreased these object stay alive. If you add them to a 
container and then later remove them again the ref count goes up to one 
first and then is decreased back to zero and the object is destroyed.
I'll have a look at the FBOViewport if there something is wrong, because 
  your first example should not leak for exactly these reasons.

        Carsten

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to