Boost logo

Boost Users :

Subject: Re: [Boost-users] share_ptr reset() question
From: ÕÅÑÇö­ (kimi67300387_at_[hidden])
Date: 2009-03-19 11:00:43

of cource, no memory leak.
 check out the source code of method 'reset'.
 there is a little trick help release the memory, which is similar with Effective STL: item 17: Use "swap trick" to trim excess capacity
 good luck
 ------------------ Original ------------------
  From: "Ben"<befung_at_[hidden]>;
 Date: Thu, Mar 19, 2009 08:28 AM
 To: "boost-users"<boost-users_at_[hidden]>;
 Subject: [Boost-users] share_ptr reset() question


Consider the following:

void createSharePtr( boost::shared_ptr<int> value)
    value.reset( new int(100));

    boost::shared_ptr<int> y( new int(0));
    createSharePtr( y);

Question: Does the function createSharePtr() cause memory leak?


Boost-users mailing list

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