I checked my little example above...

It's actually using 2 gb on the stack... plus 1 gb on the heap. 


Both frame 0 and frame 1 seem to have 1gb. 


On Sun, Feb 6, 2011 at 7:16 AM, Krzysztof Czainski <1czajnik@gmail.com> wrote:
2011/2/6 Christopher Jefferson <chris@bubblescope.net>


boost::detail::sp_ms_deleter<test>

Is as big as test, and make_shared allocates one of those on the stack,  in line:

boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >() );

Chris

This looks like a very interesting drawback of make_shared, that never occoured to me. The deleter contains space for the allocated object inside itself, and is passed by value, therefore the allocated object must be small enough to fit on the stack, when using make_shared.

Is this a known thing (bug)?

Regards, Kris.

_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users



--
Michael Xu
(770)634-1738
Computer Science
Georgia Tech