Serializing large objects

Dear All,

I am trying to serialize a HashMap containing Strings as keys and and ArrayLists as values. This works fine when the number of entries is small, but does not work when the number of entries are really large, in which case anjava.lang.OutOfMemoryError: Java heap space is thrown. This happens when the number of entries is about 50,000 and the total number of objects stored in the lists exceed 500,000.

Some posts suggest that this should have been fixed in Java 1.6 but it still doesn't seem to work. Do I need to provide the "-mx" flag to get this to work, or is there another way to serialize large objects? Any thoughts welcome.

Cheers,

Fred

[696 byte] By [fw9189a] at [2007-11-27 4:52:10]
# 1
Or you could split the HashMap up in several smaller HashMaps and write these one after the other to the ObjectOutputStream? You'd have to manually resolve any cross-references between these smaller HashMaps during deserialization in case there are any.
toon_macharisa at 2007-7-12 10:06:05 > top of Java-index,Core,Core APIs...
# 2
Well u can do something with the objects u have stored in the ArrayLists,if u can use custom serialization i.e. writing only those properties which are useful to you while not writing every field of that object to the object stream.
sachin.agrawala at 2007-7-12 10:06:05 > top of Java-index,Core,Core APIs...
# 3
How about implementing custom serialization (by implementing Externalizable), and writing the values as zippied entries. As keys are strings, they can be easily zipped and the array list values should be zipped. Is it possible? ...am I crazy?. Just give it a try :-)
nrdarbhaa at 2007-7-12 10:06:05 > top of Java-index,Core,Core APIs...