views:

69

answers:

1

We needed serialization of quite large C++ class hierarchy with lots of inheritance, contraction, shared pointers, etc. I decided to use boost::serialization library.

My problem is that while compilation of this library on VS 2008 cl takes over 1 GB of RAM memory. I suppose this is caused by template-based serialization in Boost. This causes many problems with building whole project on weaker PCs. What's interesting, compilation time is not so much longer:

no serialization: 15:38 [mm:ss]
serialization:    17:06 [mm:ss]

My question is: is it possible to cut the memory usage? Maybe with longer compilation time?

Edit

This increase of used memory happens in several files during compilation of C++/CLI project which actually uses serialization from the library above. Without serialization cl.exe has peak memory on the largest file about 150 MB, usually not more than 80. Increase of memory use is about 4 to 8 times on several files.

+1  A: 

I encountered the same problem when using boost::serialization. Probably the only workaround is to split up the huge class in more encapsulated pieces. For some classes in my code, I also wrote a layer between my application classes and the serializer. This layer simplified the structur of the data to be saved. It even separated a larger "data" part and saved it using libz (the zip library) instead of using serialization everywhere.

Danvil
Great solution, thank you for your answer.
Archie