Hi all,

Im using boost serialization to serialize a base class and his derived classes. Like this:

ParameterList is a list of parameters and parameters could be different types of parameters (string, blah blah blah).


Im serializing well, and everything is going fine but with valdrind I can see a leak and i dont know why, because the way of I am serializing into the file is the same that is made in the tutorial. Like this:

// create and open a character archive for output
std::ofstream ofs(dataFilename.str().c_str(), std::ios::binary | std::ios::app);
boost::archive::binary_oarchive persistenceFile(ofs);
persistenceFile << activeMessage;
logMessage << "Object serialized :" << activeMessage.getText() << "in position " << lastWrote;


Valgrind shows me this information:


=6208== 2,200 (2,000 direct, 200 indirect) bytes in 100 blocks are definitely lost in loss record 3 of 7
==6208==    at 0x40243C5: operator new(unsigned int) (vg_replace_malloc.c:214)
==6208==    by 0x41201E3: boost::archive::detail::heap_allocator<BytesParameter>::doesnt_have_new_operator::invoke() (iserializer.hpp:247)
==6208==    by 0x411FBAE: boost::archive::detail::heap_allocator<BytesParameter>::invoke() (iserializer.hpp:257)
==6208==    by 0x411EC94: boost::archive::detail::pointer_iserializer<boost::archive::binary_iarchive, BytesParameter>::load_object_ptr(boost::archive::detail::basic_iarchive&, void*&, unsigned int) const (iserializer.hpp:299)
==6208==    by 0x4C9879B: boost::archive::detail::basic_iarchive::load_pointer(void*&, boost::archive::detail::basic_pointer_iserializer const*, boost::archive::detail::basic_pointer_iserializer const* (*)(boost::serialization::extended_type_info const&)) (in /usr/lib/libboost_serialization.so.1.42.0)
==6208==    by 0x412728D: void boost::archive::detail::load_pointer_type<boost::archive::binary_iarchive>::invoke<Parameter*>(boost::archive::binary_iarchive&, Parameter*&) (iserializer.hpp:512)
==6208==    by 0x4127216: void boost::archive::load<boost::archive::binary_iarchive, Parameter*>(boost::archive::binary_iarchive&, Parameter*&) (iserializer.hpp:580)
==6208==    by 0x41271D5: void boost::archive::detail::common_iarchive<boost::archive::binary_iarchive>::load_override<Parameter*>(Parameter*&, int) (common_iarchive.hpp:68)
==6208==    by 0x4127190: void boost::archive::basic_binary_iarchive<boost::archive::binary_iarchive>::load_override<Parameter*>(Parameter*&, int) (basic_binary_iarchive.hpp:67)
==6208==    by 0x412714D: void boost::archive::binary_iarchive_impl<boost::archive::binary_iarchive, char, std::char_traits<char> >::load_override<Parameter*>(Parameter*&, int) (binary_iarchive_impl.hpp:50)
==6208==    by 0x41270D1: boost::archive::binary_iarchive& boost::archive::detail::interface_iarchive<boost::archive::binary_iarchive>::operator>><Parameter*>(Parameter*&) (interface_iarchive.hpp:61)
==6208==    by 0x412704B: void boost::serialization::nvp<Parameter*>::load<boost::archive::binary_iarchive>(boost::archive::binary_iarchive&, unsigned int) (nvp.hpp:87)
==6208== 
==6208== 2,400 bytes in 200 blocks are definitely lost in loss record 4 of 7
==6208==    at 0x40243C5: operator new(unsigned int) (vg_replace_malloc.c:214)
==6208==    by 0x412022D: boost::archive::detail::heap_allocator<RealParameter>::doesnt_have_new_operator::invoke() (iserializer.hpp:247)
==6208==    by 0x411FC8E: boost::archive::detail::heap_allocator<RealParameter>::invoke() (iserializer.hpp:257)
==6208==    by 0x411EDF0: boost::archive::detail::pointer_iserializer<boost::archive::binary_iarchive, RealParameter>::load_object_ptr(boost::archive::detail::basic_iarchive&, void*&, unsigned int) const (iserializer.hpp:299)
==6208==    by 0x4C9879B: boost::archive::detail::basic_iarchive::load_pointer(void*&, boost::archive::detail::basic_pointer_iserializer const*, boost::archive::detail::basic_pointer_iserializer const* (*)(boost::serialization::extended_type_info const&)) (in /usr/lib/libboost_serialization.so.1.42.0)
==6208==    by 0x412728D: void boost::archive::detail::load_pointer_type<boost::archive::binary_iarchive>::invoke<Parameter*>(boost::archive::binary_iarchive&, Parameter*&) (iserializer.hpp:512)
==6208==    by 0x4127216: void boost::archive::load<boost::archive::binary_iarchive, Parameter*>(boost::archive::binary_iarchive&, Parameter*&) (iserializer.hpp:580)
==6208==    by 0x41271D5: void boost::archive::detail::common_iarchive<boost::archive::binary_iarchive>::load_override<Parameter*>(Parameter*&, int) (common_iarchive.hpp:68)
==6208==    by 0x4127190: void boost::archive::basic_binary_iarchive<boost::archive::binary_iarchive>::load_override<Parameter*>(Parameter*&, int) (basic_binary_iarchive.hpp:67)
==6208==    by 0x412714D: void boost::archive::binary_iarchive_impl<boost::archive::binary_iarchive, char, std::char_traits<char> >::load_override<Parameter*>(Parameter*&, int) (binary_iarchive_impl.hpp:50)
==6208==    by 0x41270D1: boost::archive::binary_iarchive& boost::archive::detail::interface_iarchive<boost::archive::binary_iarchive>::operator>><Parameter*>(Parameter*&) (interface_iarchive.hpp:61)
==6208==    by 0x412704B: void boost::serialization::nvp<Parameter*>::load<boost::archive::binary_iarchive>(boost::archive::binary_iarchive&, unsigned int) (nvp.hpp:87)
==6208== 
==6208== 3,600 bytes in 300 blocks are definitely lost in loss record 5 of 7
==6208==    at 0x40243C5: operator new(unsigned int) (vg_replace_malloc.c:214)
==6208==    by 0x4120199: boost::archive::detail::heap_allocator<IntParameter>::doesnt_have_new_operator::invoke() (iserializer.hpp:247)
==6208==    by 0x411FA6E: boost::archive::detail::heap_allocator<IntParameter>::invoke() (iserializer.hpp:257)
==6208==    by 0x411EB38: boost::archive::detail::pointer_iserializer<boost::archive::binary_iarchive, IntParameter>::load_object_ptr(boost::archive::detail::basic_iarchive&, void*&, unsigned int) const (iserializer.hpp:299)
==6208==    by 0x4C9879B: boost::archive::detail::basic_iarchive::load_pointer(void*&, boost::archive::detail::basic_pointer_iserializer const*, boost::archive::detail::basic_pointer_iserializer const* (*)(boost::serialization::extended_type_info const&)) (in /usr/lib/libboost_serialization.so.1.42.0)
==6208==    by 0x412728D: void boost::archive::detail::load_pointer_type<boost::archive::binary_iarchive>::invoke<Parameter*>(boost::archive::binary_iarchive&, Parameter*&) (iserializer.hpp:512)
==6208==    by 0x4127216: void boost::archive::load<boost::archive::binary_iarchive, Parameter*>(boost::archive::binary_iarchive&, Parameter*&) (iserializer.hpp:580)
==6208==    by 0x41271D5: void boost::archive::detail::common_iarchive<boost::archive::binary_iarchive>::load_override<Parameter*>(Parameter*&, int) (common_iarchive.hpp:68)
==6208==    by 0x4127190: void boost::archive::basic_binary_iarchive<boost::archive::binary_iarchive>::load_override<Parameter*>(Parameter*&, int) (basic_binary_iarchive.hpp:67)
==6208==    by 0x412714D: void boost::archive::binary_iarchive_impl<boost::archive::binary_iarchive, char, std::char_traits<char> >::load_override<Parameter*>(Parameter*&, int) (binary_iarchive_impl.hpp:50)
==6208==    by 0x41270D1: boost::archive::binary_iarchive& boost::archive::detail::interface_iarchive<boost::archive::binary_iarchive>::operator>><Parameter*>(Parameter*&) (interface_iarchive.hpp:61)
==6208==    by 0x412704B: void boost::serialization::nvp<Parameter*>::load<boost::archive::binary_iarchive>(boost::archive::binary_iarchive&, unsigned int) (nvp.hpp:87)
==6208== 
==6208== 10,300 (3,600 direct, 6,700 indirect) bytes in 300 blocks are definitely lost in loss record 7 of 7
==6208==    at 0x40243C5: operator new(unsigned int) (vg_replace_malloc.c:214)
==6208==    by 0x4120277: boost::archive::detail::heap_allocator<StringParameter>::doesnt_have_new_operator::invoke() (iserializer.hpp:247)
==6208==    by 0x411FD6E: boost::archive::detail::heap_allocator<StringParameter>::invoke() (iserializer.hpp:257)
==6208==    by 0x411EF4C: boost::archive::detail::pointer_iserializer<boost::archive::binary_iarchive, StringParameter>::load_object_ptr(boost::archive::detail::basic_iarchive&, void*&, unsigned int) const (iserializer.hpp:299)
==6208==    by 0x4C9879B: boost::archive::detail::basic_iarchive::load_pointer(void*&, boost::archive::detail::basic_pointer_iserializer const*, boost::archive::detail::basic_pointer_iserializer const* (*)(boost::serialization::extended_type_info const&)) (in /usr/lib/libboost_serialization.so.1.42.0)
==6208==    by 0x412728D: void boost::archive::detail::load_pointer_type<boost::archive::binary_iarchive>::invoke<Parameter*>(boost::archive::binary_iarchive&, Parameter*&) (iserializer.hpp:512)
==6208==    by 0x4127216: void boost::archive::load<boost::archive::binary_iarchive, Parameter*>(boost::archive::binary_iarchive&, Parameter*&) (iserializer.hpp:580)
==6208==    by 0x41271D5: void boost::archive::detail::common_iarchive<boost::archive::binary_iarchive>::load_override<Parameter*>(Parameter*&, int) (common_iarchive.hpp:68)
==6208==    by 0x4127190: void boost::archive::basic_binary_iarchive<boost::archive::binary_iarchive>::load_override<Parameter*>(Parameter*&, int) (basic_binary_iarchive.hpp:67)
==6208==    by 0x412714D: void boost::archive::binary_iarchive_impl<boost::archive::binary_iarchive, char, std::char_traits<char> >::load_override<Parameter*>(Parameter*&, int) (binary_iarchive_impl.hpp:50)
==6208==    by 0x41270D1: boost::archive::binary_iarchive& boost::archive::detail::interface_iarchive<boost::archive::binary_iarchive>::operator>><Parameter*>(Parameter*&) (interface_iarchive.hpp:61)
==6208==    by 0x412704B: void boost::serialization::nvp<Parameter*>::load<boost::archive::binary_iarchive>(boost::archive::binary_iarchive&, unsigned int) (nvp.hpp:87)



what could be? any idea?



regards!

--
Óscar Pernas Plaza.