• Advertisement
Sign in to follow this  

Optimizing the Serializing of Objects in Java

This topic is 4261 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey, I've begun to notice something like this with large objects that I serialize in Java: -Suppose a program is using 50 megs of memory before serialization -All the objects are serialized in order to 'save the state' of the program, if we wanted to restart the program from a given moment in time. It creates a file 18 megs in size. -Upon deserialization, the program is using almost 100 megs of memory! Has anyone noticed this type of problem before, or is it something I'm doing wrong with the way I'm serializing objects...to me it doesnt make sense that if I am essentially loading the state of a program thats been saved to file for my memory usage to be so much higher. Any insights will be appreciated.

Share this post


Link to post
Share on other sites
Advertisement
Well, doing the unserialization prolly requires some intermediate storing of data, and as Java is automatically garbage collecting, it also means it doesn't unless it has to.

So my guess is that most of that is just dead memory, trying forcing garbage collection after loading and see how much it uses.

Share this post


Link to post
Share on other sites
it actually might have been that memory that originally was in the swap space was being loaded into ram, therefore making the memory usage to be much higher.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement