On a production application using DWR 2.0.9, I noticed that the number of entries in DefaultScriptSessionManager's pageSessionMap increases forever. This application's use of Spring Webflow 1.0.4 (old!), causes it to continually generate new unique URLs, each time a flow is entered by a user. As a result, I'm seeing tens of thousands of entries in pageSessionMap, which appears to degrade performance. In a 'normal' app, I'd expect the number of unique URLs for an app to be fairly limited. Here's an example of the created URLs:
The unique flow ID isn't part of the query string, so it's not stripped by PageNormalizer.normalizePage.
Just to be clear, inactive sessions are being invalidated/removed from sessionMap (based on the default 5 minute check), but entries in pageSessionMap itself are never removed.
The invalidate method iterates over pageSessionMap, and for each entry (a set), removes the scriptSession from that set. But once that set becomes size zero, nothing ever removes the empty set from pageSessionMap.
This lack of cleanup is probably only an issue for applications that service a large number of URLs (as with older versions of spring webflow).
My observation of this has been based on looking at the 2.0.9 code and tests of the application on that version. I am marking this as 'affects versions' 2.0.9 and 2.0.10 (really 2.0.X), as well as 3.0.RC2, though I have not confirmed the same behavior on the latter, and DefaultScriptSessionManager has changed around significantly enough that I'm unsure if it's still an issue.
In the meantime, I am able to work around this, with an alternate implementation for method invalidate that removes the pageSessionMap entry when its session set is empty.
See [dwr-dev] Management of page session map for more discussion.
David - thanks and sorry for the delay - was otherwise occupied late last week. Should be able to try it out against our codebase this week.
I picked up the change to the invalidate method, and it works as expected to perform the needed cleanup. Many thanks!
Thanks for the response Geoff, glad it is working for you.