Binary binary crashes

First, I fill out a structure that is quite large and has interconnections. and then I serialize it in a binary archive. The size of this structure depends on what data I pass to the program. I see that the program takes ~ 2 GB of memory to build the expected and acceptable structure.

Then I start serializing the object. and I see that the program eats RAM during serialization. The use of RAM is increased to 100%. swap usage is still 0 bytes.

and then the application crashes. except for bad_alloc on new

Why does the serialization process require so much RAM and time? and why does it crash when allocating memory when the swap is empty? The backtrace is too long to insert completely.

 #0 0xb7fe1424 in __kernel_vsyscall () #1 0xb7c6e941 in raise (sig=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64 #2 0xb7c71e42 in abort () at abort.c:92 #3 0xb7e92055 in __gnu_cxx::__verbose_terminate_handler() () from /usr/lib/libstdc++.so.6 #4 0xb7e8ff35 in ?? () from /usr/lib/libstdc++.so.6 #5 0xb7e8ff72 in std::terminate() () from /usr/lib/libstdc++.so.6 #6 0xb7e900e1 in __cxa_throw () from /usr/lib/libstdc++.so.6 #7 0xb7e90677 in operator new(unsigned int) () from /usr/lib/libstdc++.so.6 #8 0xb7f00a9f in boost::archive::detail::basic_oarchive_impl::save_pointer(boost::archive::detail::basic_oarchive&, void const*, boost::archive::detail::basic_pointer_oserializer const*) () from /usr/lib/libboost_serialization.so.1.42.0 #9 0xb7effb42 in boost::archive::detail::basic_oarchive::save_pointer(void const*, boost::archive::detail::basic_pointer_oserializer const*) () from /usr/lib/libboost_serialization.so.1.42.0 #10 0x082d052c in void boost::archive::detail::save_pointer_type<boost::archive::binary_oarchive>::non_polymorphic::save<gcl::NestedConnection<gcl::Section, gcl::NestedConnection<gcl::Paragraph, gcl::NestedConnection<gcl::Line, void> > > >(boost::archive::binary_oarchive&, gcl::NestedConnection<gcl::Section, gcl::NestedConnection<gcl::Paragraph, gcl::NestedConnection<gcl::Line, void> > >&) () #11 0x082d0472 in void boost::archive::detail::save_pointer_type<boost::archive::binary_oarchive>::save<gcl::NestedConnection<gcl::Section, gcl::NestedConnection<gcl::Paragraph, gcl::NestedConnection<gcl::Line, void> > > >(boost::archive::binary_oarchive&, gcl::NestedConnection<gcl::Section, gcl::NestedConnection<gcl::Paragraph, gcl::NestedConnection<gcl::Line, void> > > const&) () ....... #172 0x082a91d8 in boost::archive::detail::interface_oarchive<boost::archive::binary_oarchive>::operator<< <gcl::Collation const> (this=0xbfffe500, t=...) at /usr/include/boost/archive/detail/interface_oarchive.hpp:64 #173 0x082a6298 in boost::archive::detail::interface_oarchive<boost::archive::binary_oarchive>::operator&<gcl::Collation> (this=0xbfffe500, t=...) at /usr/include/boost/archive/detail/interface_oarchive.hpp:72 #174 0x0829bd63 in main (argc=4, argv=0xbffff3f4) at /home/neel/projects/app/main.cpp:93 
  • The program works correctly when smaller data is fed to it.
  • Using Linux 64-bit with 32-bit PAE 1.42 kernel
  • the program worked flawlessly a few changes back. I recently added some structures to the structures. maybe then he did not reach the end of RAM and now its achievements.

But why a new crash when there is a swap? Why does the serialization process require so much RAM?

+4
source share
2 answers

I realized that the serialization process requires additional memory for your own household chores. and pressed 3GB Barrier To stop the serialization process from using additional memory, I turned off the tracking of BOOST_CLASS_TRACKING objects and that the additional memory overhead was fixed.

+1
source

Question: why does it crash when allocating memory when the swap is empty?

The selected object is too large to fit anywhere in the virtual address space :

If your application runs as 32 bits, the virtual address space process is limited to 4Gb.

Question: Why does the serialization process require so much RAM?

I did not find any evidence.

+1
source

All Articles