EJB programming & troubleshooting: EJB - Serializable Object Passing - Garbage Collection

  1. Hi, I want to know how the serializable objects returned by the session bean to the client garbage collected in the server. Please find below the details. AccountBean - Method defined in the AccountBean [Session Bean] public Accounts getAccounts( String accountType) Accounts public class Accounts implements Serializable { public Accounts( String accountType, long timestamp, AdvAccount[] advAccountsArray) { this.timeStamp = timestamp; this.advAccountsArray = advAccountsArray; this.accountType = accountType; } } AdvAccount - Java Bean with getters/setters - Serializable When i invoke the bean from a client, Account Bean talks to DB and returns the number of Account object which inturn contains number of AdvAccount objects. For an example particular search results 438 AdvAccount objects. This is being returned to the client. Since Accounts is a serialized object in the server when this object is garbage collected in the server? When i run JProbe i could see these 438 AdvAccount objects are in memory. Even when i force to do gargabe collection these objects never garbage collected and stay in memory. Please guide me. I am using WSAD and WebSphere 5.0.2 and JProbe 6.0.2 Thanks Selva
  2. Selva, In my opinion... once the object is serialized and de-serialized... it means the object is transformed to an intermediate form and then back to object. So it should be eligible for garbage collection after the serialization. How ever now a new object with same amount of data is on the Client side. Are you sure you are making this object eligible for garbage collection ? Can you see in Jprobe who is referring to this object in memory? Krishna
  3. Krishna, Thanks for your reply. Client side i am setting the objects to NULL. Initially after getting the EJB home object reference we are not calling the remove method on the EJB Object. Now i am doing that too. To test why the server side serializable objects are stored in memory before sending the objects to the client i am setting the object array itself to null. At that time JProbe created 438 objects and when i invoke GC all the objects are garbage collected. Since i am returning null i am getting null pointer exception in the client side. From this i make sure that once i send all the objects to the client i dont know how to reclaim those objects on the server side. How to see what are referring those objects in JProbe? Thanks Selva
  4. This might sound like a dumb question, but is AccountBean a stateless session bean, or a stateful session bean? Also, what's the implementation for getAccounts()? Is it possible something is caching the AdvAccounts?