Boost logo

Boost Users :

Subject: [Boost-users] [Q] eliminating false memory leak reports
From: V S P (toreason_at_[hidden])
Date: 2009-03-30 17:36:47

I have a class (below),
and MS memory leak detector reports a leak
on ptr.reset

I have redefined 'new' as follows:

 #define MYDEBUG_NEW new( _NORMAL_BLOCK, __FILE__, __LINE__)

In another example, also below I have
an _impl structure that is allocated and assign
typedef boost::shared_ptr<cmoney_impl_dtl> t_money_storage;

My understanding is that it is a 'false' detection
is that correct?

In otherwords, in my thinking -- as long as I have assigned an object
to boost::shared_ptr -- I do not have remember anything about it

(using visual studio 2008, 32 bit)

Another question, since I have all of my heap objects using
is there any free tool that I can use to verify that those things do not
(as some of the are actually DB connections so it is important for them
get completely destroyed).

Thank you in advance


template <typename TThrdData>
struct CService_ThreadData:private boost::noncopyable
   CService_ThreadData (void){};
   ~CService_ThreadData (void){};

///creates a new thread data object if does not exists
//Call this from every thread to establish thread's data
//manager object
static TThrdData& getdata(void)
   /* YES, using static variable in this case is safe,
   because it is in the 'global' scope and therefore
   is intialized before Main starts
   Otherwise, static variables are not thread safe
   if (ptr.get() == 0)
      ptr.reset(new TThrdData());
   return (TThrdData&)(*ptr);

   static boost::thread_specific_ptr<TThrdData> ptr;

};//end of class


cmoney_t::cmoney_t (void)
   :v(new cmoney_impl_dtl)


  V S P
-- - Access your email from home and the web

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at