Boost logo

Boost Users :

Subject: Re: [Boost-users] why is make_shared using so much of my stack....?
From: Christopher Jefferson (chris_at_[hidden])
Date: 2011-02-06 04:54:05


On 6 Feb 2011, at 03:00, Michael Xu wrote:

> Actually, I put both methods with new and make_shared in there to illustrate
> the point.
>
> When I run it JUST with new. It completes. When I run it JUST with
> make_shared it fails.
>
> I'm also running on a x86_64 linux machine with 6 gb of ram.
>
> I asked this on the #boost channel on freenode.net, everyone thought I was
> confusing stack with heap as well.. but that's not the case... comparing the
> stack pointers in each frame using "info register' in gdb tells me that the
> space used by the frames in that stack trace are unreasonably large.

I am not knowledgable about the inner details of boost::shared_ptr, but the problem is that:

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


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net