In a j2ee webapp we have a search object that stores a user's search preferences (items/page, detail level, etc). it has a search() that calls a static method getSearcher() that returns a static IndexSearcher that all these user search objects use.....searching with that gives us a Hits object that this user object iterates through to find out what categories are used, which ones to display, etc. this hits object is huge. Its fluffing up each user session by 20M in some cases. This is unacceptable of course. I am sure many have run into this issue, and I was curious what you did to solve it. If I use a local variable to that search method, null it after I'm done and call gc(), it still is bad. I can't put the hits variable into a static object or attribute cause of course there are multiple of these user search objects using it at any time. Even if I isolated the user search part to a singleton, others may use it at the same time as well. I imagine some sort of synchronization of that static variable is in order but am not quite sure. does someone have an example of this? I would image everyone has had to deal with this problem. 20M is just to big. When we use a profiler we find that it's a char[] that seems to be holding a lot of the data..like 16M of it. For different indexes in different servers, this size is different, but for the most part its way to big everywhere.
Thoughts? I appreciate any help on this. Thanks