11 Aug
2010
11 Aug
'10
8:25 p.m.
AMDG gast128 wrote:
We use boost a lot and also the intrusive_ptr to wrap ref counted objects. However the intuitive behavior gives memory leaks. For example use a ref counted object KFoo:
intrusive_ptr<IFoo> ptr(new KFoo); // mleak, KFoo is extra ref counted ptr.reset(new KFoo) //mleak
ptr = intrusive_ptr<IFoo>(new KFoo, false); //ok, but Spartan way of writing
Perhaps you should initialize the reference count to zero in the constructor of IFoo, instead of initializing it to 1. In Christ, Steven Watanabe