After deserialization program occupies about 66% more RAM

S

setar

Ok. Here are results:)
After deserialization program occupies more memory, but large part of heap
is free (it isn't used by any object). Llike Thomas wrote it is probably
caused by this that during deserialization stream occupies large part of
heap and when I close the stream this part becomes free, but it isn't
returned to operating system.
More exactly, I must run garbage collection about three times if I want the
amount of used heap to return to state nearly the same as before
serialization.
I also compared number of object of each class and amount of heap used by
them before serialization and after deserialization. For most classes the
numbers of objects are the same or nearly the same. But after
deserialization there is 7% more objects of char[] (I don't use them - they
are only used internally by String), but they occupy 2MB less memory:) As
Robert wrote I think it could be so because in dictionary before
serialization part of strings share char[] tables with other strings. After
deserialization for these strings new char[] tables will be created (so the
number of them will grow). But also, char[] tables that existed before
serialization only because sharing (they were no other references to them)
won't be created. Because oryginal char[] tables were longer than new tables
they can occupy less memory than before serialization.

Thanks all!
 
R

Robert Klemme

setar said:
Ok. Here are results:)
After deserialization program occupies more memory, but large part of heap
is free (it isn't used by any object). Llike Thomas wrote it is probably
caused by this that during deserialization stream occupies large part of
heap and when I close the stream this part becomes free, but it isn't
returned to operating system.
More exactly, I must run garbage collection about three times if I want the
amount of used heap to return to state nearly the same as before
serialization.
I also compared number of object of each class and amount of heap used by
them before serialization and after deserialization. For most classes the
numbers of objects are the same or nearly the same. But after
deserialization there is 7% more objects of char[] (I don't use them - they
are only used internally by String), but they occupy 2MB less memory:) As
Robert wrote I think it could be so because in dictionary before
serialization part of strings share char[] tables with other strings. After
deserialization for these strings new char[] tables will be created (so the
number of them will grow). But also, char[] tables that existed before
serialization only because sharing (they were no other references to them)
won't be created. Because oryginal char[] tables were longer than new tables
they can occupy less memory than before serialization.

Thanks all!

Thank /you/ for sharing these results.

robert
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,119
Latest member
IrmaNorcro
Top