I found something interesting while profiling our application. I noticed 8.3 MB of memory allocated to int16 arrays. Digging down further I found that these all originated in NHibernate.Hql.Ast.ANTLR.HqlLexer for static readonly field DFA23_transition. Here is the variable definition
static readonly short DFA23_transition = DFA.UnpackEncodedStringArray(DFA23_transitionS);
When setting a breakpoint on this the arrays first dimension is 346 and the second dimension varies between 0 - 65526
Total memory usage for the array ends up being around 8.3 meg. I then started looking at what causes this class to be used and narrowed it down to a named queries. We only have one named query defined in our hbm.xml files and if I remove that then I do not see this class get used.
Can anyone explain what this is doing and why its using so much memory. Our application is a web application and we have hundreds of instances running. 8.3mb doesn't seem like much but it adds up quick with that many instances.