<DIV>of cource, no memory leak.</DIV> <DIV>check out the source code of method 'reset'.</DIV> <DIV>there is a little trick help release the memory, which is similar with Effective STL: item 17: Use "swap trick" to trim excess capacity</DIV> <DIV> </DIV> <DIV>good luck</DIV> <DIV><includetail> <DIV> </DIV> <DIV> </DIV> <DIV style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 12px; PADDING-BOTTOM: 2px; PADDING-TOP: 2px; FONT-FAMILY: Arial Narrow">------------------ Original ------------------</DIV> <DIV style="FONT-SIZE: 12px"> <DIV id=menu_sender><B>From: </B> "Ben"<befung@gmail.com>;</DIV> <DIV><B>Date: </B> Thu, Mar 19, 2009 08:28 AM</DIV> <DIV><B>To: </B> "boost-users"<boost-users@lists.boost.org>; </DIV> <DIV></DIV> <DIV><B>Subject: </B> [Boost-users] share_ptr reset() question</DIV></DIV> <DIV> </DIV> <DIV style="FONT-WEIGHT: normal">Hello,<BR><BR>Consider the following:<BR><BR>void createSharePtr( boost::shared_ptr<int> value)<BR>{<BR> value.reset( new int(100));<BR>}<BR><BR>main()<BR>{<BR> boost::shared_ptr<int> y( new int(0));<BR> createSharePtr( y);<BR>};<BR><BR>Question: Does the function createSharePtr() cause memory leak? <BR><BR>Thanks,<BR>Ben<BR><BR>_______________________________________________<BR>Boost-users mailing list<BR>Boost-users@lists.boost.org<BR>http://lists.boost.org/mailman/listinfo.cgi/boost-users</DIV></includetail></DIV>