Carsten Neumann wrote:
>       Hi Antonio,
> 
> On Mon, 2007-09-10 at 20:33 +0200, Antonio Bleile wrote:
>> Hi,
>> Dirk Reiners wrote:
>>> Antonio Bleile wrote:
>>>> I'm currently writing some unit-tests for my application,
>>>> in each test I'd like to start with osgInit and end
>>>> with osgExit (in order to detect memleaks!). But it seems
>>>> as if the osgInit/Exit pair should be just called once
>>>> withing a process instance.
>>>> Is this correct? (After the second osgInit I can't
>>>> create any OSG instances (they seem to be null)).
>>> I don't think we ever considered supporting that. ..
>>>
>>> I'm not sure how easy it would be to implement, as we use quite a bit of 
>>> static 
>>> inits, which cannot be redone, so some parts would have to stay around.
>> Ok....
>>
>>> I think most memleaks can also be found by just testing all FCs that you 
>>> create 
>>> are actually destroyed at the end of the test. Just be aware that the 
>>> Prototypes 
>>> are in teh FCFactory, too, so you need to ignore those when checking. For 
>>> more 
>> Mh.... Not sure if I got you here. How am I supposed to test all FCs?
> 
> osgInit(argc, argv);
> 
> // before anything is created, get the size of the store, which at this
> // point only contains the prototypes.
> UInt32 fcStoreSize = FieldContainerFactory::the()-
>> getFieldContainerStore()->size();
> 
> 
> // your program goes here ;)
> 
> 
> FieldContainerFactory::FieldContainerStoreIt fcIt =
> FieldContainerFactory::the()->getFieldContainerStore()->begin();
> FieldContainerFactory::FieldContainerStoreIt fcEnd =
> FieldContainerFactory::the()->getFieldContainerStore()->end();
> 
> // move iterator past the prototypes
> fcIt += fcStoreSize;
> 
> for(; fcIt != fcEnd; ++fcIt)
> {
>     if(*fcIt == NullFC)
>         std::cerr << "Detected live FC!" << std::endl;
> }
> 
> I'm not entirely sure this works after osgExit has run, but on the other
> hand it should only require information from the FCPtrs to do the
> compare.

Your implementation did not compile with my version....
(something lik eimpossible to acces protected typedef in
class FieldContainerFactory..., whatever)

So here's the version without iterators, should be equivalent...

     osgExit();

     const std::vector<FieldContainerPtr> &fcs = 
*FieldContainerFactory::the()->getFieldContainerStore();

     int notNull = 0;
     for(int i=fcStoreSize;i<fcs.size();++i)
     {
         FieldContainerPtr fc = fcs[i];
         if(fc != NullFC)
         {
              notNull++;
              printf( "Detected living FC!\n");
         }
     }

     printf( "%d out of %d FC's are not destroyed\n", notNull, 
fcs.size()-fcStoreSize );

I get 169 out of 180 FC's still living. That's quite a leak.... Will
check. Thank you for the hint!

   Toni

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to