Hi,
I've come across a couple of memory leaks in Dbo. The code is attached.
Version of Wt is 3.1.3.
The first leak is straight-forward to fix: delete any pointers in the
class registry before overwriting (or my preferred solution: use a smart
pointer.) In my opinion, an API like Dbo should not allow this usage. It
should either throw an exception or have a mechanism by which to
determine if a class has already been mapped. It most definitely should
not leak.
The second leak is a bit weirder and I'm not sure what is going on. I've
gone through the code and as far as I can tell, the transaction's
objects are deleted in the destructor. I've included the valgrind trace
as well.
Thanks in advance!
--
Sohail Somani
--
iBlog : http://uint32t.blogspot.com
iTweet: http://twitter.com/somanisoftware
iCode : http://bitbucket.org/cheez
KIMI_UNIT_TEST( TestWtMapClassMemoryLeak )
{
dbo::backend::Sqlite3 connection(":memory:");
dbo::Session session;
session.setConnection(connection);
session.mapClass<Class>("class");
session.mapClass<Class>("class"); // Second one leaks
}
KIMI_UNIT_TEST( TestWtFlushLeak )
{
dbo::backend::Sqlite3 connection(":memory:");
dbo::Session session;
session.setConnection(connection);
session.mapClass<Class>("class");
Wt::Dbo::Transaction t(session);
dbo::ptr<Class> klass(new Class);
klass.modify()->integer = 5;
session.add(klass);
t.commit(); // This leaks...
}
==27331== 44 (8 direct, 36 indirect) bytes in 1 blocks are definitely lost in
loss record 3 of 3
==27331== at 0x402569A: operator new(unsigned int) (vg_replace_malloc.c:255)
==27331== by 0x80A2A9E: void
Wt::Dbo::Session::implSave<Class>(Wt::Dbo::MetaDbo<Class>&) (Session_impl.h:180)
==27331== by 0x80A2561: Wt::Dbo::MetaDbo<Class>::flush() (ptr_impl.h:45)
==27331== by 0x80B5D88: Wt::Dbo::Session::flush() (Session.C:155)
==27331== by 0x80B8D7C: Wt::Dbo::Transaction::Impl::commit()
(Transaction.C:77)
==27331== by 0x80B8C2A: Wt::Dbo::Transaction::commit() (Transaction.C:51)
==27331== by 0x809FFD5: TestWtFlushLeak::test_method()
(test_SchemaManager.cpp:113)
==27331== by 0x809FE82: TestWtFlushLeak_invoker() (test_SchemaManager.cpp:99)
==27331== by 0x8052084: boost::unit_test::ut_detail::unused
boost::unit_test::ut_detail::invoker<boost::unit_test::ut_detail::unused>::invoke<void
(*)()>(void (*&)()) (callback.hpp:56)
==27331== by 0x8052066:
boost::unit_test::ut_detail::callback0_impl_t<boost::unit_test::ut_detail::unused,
void (*)()>::invoke() (callback.hpp:89)
==27331== by 0x8193C38:
boost::unit_test::callback0<boost::unit_test::ut_detail::unused>::operator()()
const (callback.hpp:118)
==27331== by 0x8193BD9: boost::unit_test::(anonymous
namespace)::zero_return_wrapper_t<boost::unit_test::callback0<boost::unit_test::ut_detail::unused>
>::operator()() (unit_test_monitor.ipp:41)
------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
witty-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/witty-interest