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.
Hope it helps,
Carsten
PS: Access to the FieldContainerStore should be read only and not be
abused to do dirty tricks behind the scenes ;)
> > complicated things something like valgrind or Purify might be a better
> > tool, as
>
> I have no Linux and I have no money for Purify... :-/ But Boost's
> unit-test framework is supposed to detect memleaks for debug builds
> under windows, I also see some output but I've still not figured
> out if that is useful for me.
>
> > it also tells where the memory was allocated and leaked (which are usually
> > the
> > interesting questions ;).
>
> Yep....
>
> Thanks,
>
> 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
-------------------------------------------------------------------------
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