The number of PathDispatcherServer$Matcher instances are determined by how many paths are defined, configured and hardcoded, in our code. Even if some of compiled regex expressions would be shared as static fields it will not bring any memory gains.
The size of an object instance is proportional with the number of instance fields it has (when fields are object references, not primitive types). The rule does not apply to special objects like String or Array.
So if we want to reduce memory we should look at objects with lots of instance fields or lots of instances with a few instance fields.
I'll look through the code to see what areas are good candidates for a memory-conscious re-factoring.
As an example, for a long time I wanted to bring EnvironmentAdaptingServlet in front of the SessionDispatcher so that the detection is done per application, not per session how is it done now, thus instantiating only one EnvironmentAdaptingServlet object.
Mircea, please look for some natural ways to re-use objects in the servlet stack. Art has performed memory analysis as follows:
The memory spent per session in classes of the package com.icesoft.faces.webapp.http is 37,096 bytes in retained size (1,272 in shallow size). Note that we are including an instance of ServletExternalContext, which extends BridgeExternalContext from the context package. If we didn't count this object, the size would be 5,864 bytes per client.
There are 8 instances of PathDispatcherServer$Matcher per session, plus 7 more for the whole app. The retained size of these objects ranges from 232 to 368 bytes.