Sorry for taking so long to respond to this email. More inline...
this is the last step to handle the paged search request : cleaning the remaining paged search when they are not used.
The problem is that a client can launch a paged search, get some few pages, and then stop requesting the remaining pages, without closing the request. Obviously, this is bad, bad, bad, but we won't be able to spank all the clients ;)
The created paged search context will then remain until the session is closed, keeping all the associated data (cursors, and such) in memory. Plus the client may launch more than one paged search request, leading to a quick OOM...
There are a few strategy we can implement to avoid such a problem :
1) first, we can limit the number of paged search request per session. I guess that a session with more than 5 or 10 opened paged search is very unlikely to occur. I suggest that we limit the number of opened paged searches to 5 atm (of course, this should be configurable), and unlimited for the administartor. When we reach this number, then the oldest paged search will be removed from the session.
2) we can also manage a timeout for the paged search. That mean a thread will be in charge of removing all the time-outed paged search across the sessions.
3) We can also wait until the session dies, and cleanup the associated paged search.
In any case, we must do something, as the cursors _have_ to be closed.
Does those 3 proposals make sense to you? Did I forgot something? Do you see a better strategy ?