Hi,

Allen Bierbaum wrote:
> Hello all:
> 
> As part of our on-going effort to track down some OpenSG memory usage,
> I tried to write a function that would:
> 
> 1) Count up the number of allocated field containers (from the field
> container factory)
> 2) Print out a nice little report about how many of each class type
> have been allocated
> 
> The goal was to see if there were some object types that keep growing.
>  Then hopefully this could point to a section of the code that we
> could look at to fix the leak.
> 
> Anyway, I wrote the function below, but it didn't work.  It comes back
> thinking the type of all fc's is "FieldContainer".  I suspect
> type-pruning, but I don't see the error.  Can anyone see my mistake?
> 
> -Allen
> 
> #include <sstream>
> typedef std::map< OSG::UInt32,  OSG::UInt64> fc_type_to_count_map_t;
> 
> std::string getAllocatedFieldContainerDescription()
> {
>    // Build up the list
>    OSG::UInt64 num_allocated_fcs(0);
>    fc_type_to_count_map_t type_count_map;   // Map from type id to type count
> 
>    OSG::FieldContainerFactoryBase* fcf = OSG::FieldContainerFactory::the();
>    OSG::TypeFactoryBase* type_factory  = OSG::TypeFactory::the();
> 
>    const OSG::FieldContainerFactoryBase::ContainerStore&
> fcs(fcf->getContainerStore());
>    for(OSG::UInt64 i=0; i<fcs.size(); i++)
>    {
>       OSG::FieldContainerPtr fcp(fcs[i]);
>       if (fcp != OSG::NullFC)
>       {
>          OSG::UInt32 type_id = fcp->getClassTypeId();

                                  ^^^^^^^^^^^^^^^^^^^^^^

this is a static function that doesn't jump down the inheritance
hierarchy. Working with fcp->getType() should work as this is
the virtual function that jumps down the hierarchy.

kind regards,
   gerrit


------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to