I haven't got too much experience with serializing. But doesn't Java create new instances any time it deserializes an object? This way we would get a huge GC problem.
Yes, a new instance is created upon deserialization. However, if done correctly, there should be no issues with GC. Here is an excerpt taken from smartdataprocessing.com, lesson 11:
-----
Serializaion in the Real WorldIn some types of applications you have to write the code to serialize objects, but in many cases serialization is performed behind the scenes by various server-side containers. These are some of the typical uses of serialization:
* To persist data for future use.
* To send data to a remote computer using such client/server Java technologies as RMI or socket programming.
* To "flatten" an object into array of bytes in memory.
* To exchange data between applets and servlets.
* To store user session in Web applications.
* To activate/passivate enterprise java beans.
* To send objects between the servers in a cluster.
When you use serialization in time-critical applications, for example real- time stock trading systems, the size of the serialized objects should be minimal. Keep in mind that variables with longer names produce larger footprints during serialization, and this may substantially slow down your application. Think of a high volume of trade orders that is being serialized. I remember working on the application where a class TradeOrder had about a hundred member variables. After renaming the variables into meaningless v1, v2, and so on, the size of one TradeOrder instance was reduced by a thousand bytes. And we are talking about serializing of thousands orders over the network!
If performance is your primary goal, use Externalizable interface instead of Serializable. Yes, you'll have to write code to serialize each attribute, but this may speed up serialization process substantially.
-----
With my Request object, they can come in from the GameServer and are processed in a single method. Thus, if I did happen to have an object come in over the network and didn't do anything with it, then that object will be available for GC. Using the advice from above, I've taken care to minimize my Request object (and extra special care for those objects I place into the 'value' variable).
Is there a case you can think of where GC will be an issue?