Am 14.04.2011 16:58, schrieb Torsten Dreyer:
> Thanks for looking into this.
> A few comments on the autopilot objects:
> InputValueLists are vectors of InputValue, a subclass of SGReferenced, so 
> they 
> should be automatically deleted, once the last reference is gone?
> 
> The componentForge is a static vector, initialized only once at startup. It's 
> intention is to live during the entire session. It's never dropped, never 
> recreated and never cleared. 
The thing with maps and vectors of pointers to heap objects is that --
according to valgrind -- the heap objects are not deleted when the
parent vector is. Minimal example:
#include <vector>
int main() {
  std::vector<int*> v;
  v.push_back(new int(1));
  v.clear();
  return 0;
}
leaks 4 bytes in spite of the clear() call. It is necessary to delete
the heap objects explicitly, e.g.
  std::vector<int*>::iterator i;
  for (i=v.begin(); i != v.end(); ++i)
    delete (*i);
This doesn't happen for static variables nor for data members. I'd
assume that in case of SGReferenced objects, the same explicit delete is
necessary to decrement the reference counter.
In any case, the static variables and probably the complete autopilot
are only destroyed at program end, so fixing these leaks won't have an
influence on the growing memory footprint at runtime. I just mentioned
them because they were the only ones where I thought an easy fix to be
possible.

Best regards,
        Andreas

------------------------------------------------------------------------------
Benefiting from Server Virtualization: Beyond Initial Workload 
Consolidation -- Increasing the use of server virtualization is a top
priority.Virtualization can reduce costs, simplify management, and improve 
application availability and disaster protection. Learn more about boosting 
the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev
_______________________________________________
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel

Reply via email to