RE: [Boost-users] Re: Using shared_ptr across shared library boun dary
David Abrahams wrote:
"Edward Diener"
writes: Is there any problem with using shared_ptr and passing an instance of it to a function in another shared library, such as a DLL under Windows ?
Works beautifully, even if the two DLLs are using different heaps. Are you sure about the different heaps? It's been my experience (with Visual Studio, at least) that allocating memory in one DLL and deallocating it in another leads to problems. Sometimes it doesn't go noticed, but when it does, it's really noticeable.
-- Jim Hyslop Senior Software Designer Leitch Technology International Inc. (http://www.leitch.com) Columnist, C/C++ Users Journal (http://www.cuj.com/experts)
"Jim.Hyslop"
David Abrahams wrote:
"Edward Diener"
writes: Is there any problem with using shared_ptr and passing an instance of it to a function in another shared library, such as a DLL under Windows ?
Works beautifully, even if the two DLLs are using different heaps.
Are you sure about the different heaps?
Positively.
It's been my experience (with Visual Studio, at least) that allocating memory in one DLL and deallocating it in another leads to problems. Sometimes it doesn't go noticed, but when it does, it's really noticeable.
The library cleverly avoids that, provided the first shared_ptr to take ownership of the memory does so in the same DLL where the object was allocated. -- Dave Abrahams Boost Consulting www.boost-consulting.com
participants (2)
-
David Abrahams
-
Jim.Hyslop