I am maintaining a legacy GUI application running on Tomcat6 and in some cases, when an user logs in, the application loads a massive java object into session and it takes a lot of memory (up to 200MB). I installed psi-probe to monitor the memory and it shows this:
Current memory usage is 99.3%
Free: 3.41 MB Total: 487.25 MB Max: 487.25 MB
I would like to avoid touching the structure of the object itself because it is also a monster of complexity and I would probably break something. I don't really know what options I have. I was thinking of trying to serialize it and write it as a file on the drive and access it there on demand.
Any ideas?
Cheers.
If you want to not load the large object into the session, you will need to load a place holder into the session then use the place holder to get access to the object or the data in the object.
One technique is to create one or more rows in a database that contain the same data as is in the large object, store a key to the row (or rows) in the session, then use the key to access the data. This will avoid using the large object.