[boost-users][test] Does memory leak detection work in linux?

Hi all, Does memory leak detection work in linux? -- Regards, Andrey

Andrey Torba <andreytorba <at> gmail.com> writes:
Hi all,Does memory leak detection work in linux?-- Regards, Andrey
If you refer to the execution monitor, the answer is no. If you refer to the exception safety test mechanisms, they should be portable.

How can i check basic exception safety without detecting memory leaks? Windows version says that the code below isn't exception safe, but linux version says nothing. #define BOOST_TEST_MAIN #include <boost/test/unit_test.hpp> #include <boost/test/exception_safety.hpp> #include <boost/test/mock_object.hpp> using namespace boost::itest; // Boost #include <boost/shared_ptr.hpp> template<class T1, class T2> void algo(boost::shared_ptr<T1> x, boost::shared_ptr<T2> y) { } typedef mock_object<> Mock; typedef boost::shared_ptr<Mock> SharedMock; BOOST_TEST_EXCEPTION_SAFETY( TestCase1 ) { algo(SharedMock( new Mock() ), // memory leak in case of second Mock throws exception SharedMock( new Mock() )); } -- Regards, Andrey

Andrey Torba wrote:
How can i check basic exception safety without detecting memory leaks? Windows version says that the code below isn't exception safe, but linux version says nothing.
#define BOOST_TEST_MAIN #include <boost/test/unit_test.hpp> #include <boost/test/exception_safety.hpp> #include <boost/test/mock_object.hpp> using namespace boost::itest;
// Boost #include <boost/shared_ptr.hpp>
template<class T1, class T2> void algo(boost::shared_ptr<T1> x, boost::shared_ptr<T2> y) { }
typedef mock_object<> Mock; typedef boost::shared_ptr<Mock> SharedMock;
BOOST_TEST_EXCEPTION_SAFETY( TestCase1 ) { algo(SharedMock( new Mock() ), // memory leak in case of second Mock throws exception SharedMock( new Mock() )); }
This may or may not work depending on the order that the compiler does things. Most likely, on windows, the compiler is creating the two new Mocks and then passing them to the shared_ptr constructors. On Linux, it's probably passing each new Mock to shared_ptr as soon as it's constructed. In Christ, Steven Watanabe

You are right On 4 March 2010 17:53, Steven Watanabe <watanabesj@gmail.com> wrote:
This may or may not work depending on the order that the compiler does things. Most likely, on windows, the compiler is creating the two new Mocks and then passing them to the shared_ptr constructors. On Linux, it's probably passing each new Mock to shared_ptr as soon as it's constructed.
In Christ, Steven Watanabe
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
-- Regards, Andrey
participants (3)
-
Andrey Torba
-
Gennadiy Rozental
-
Steven Watanabe