You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate has the potential to leak memory via its parsedSqlCache property.
The code only ever adds to the Map and does not limit its size in any way.
Nothing in the Javadoc makes developers aware that this Map could potentially grow without bounds.
We encountered this problem only under live load. The search on our website has the potential to generate a large number of permutations. We were thus dynamically generating a large number of unique SQL statements.
We do use bind params where possible but there are places where this is difficult or inconvenient.
The size of these statements as String keys, stored within NamedParameterJdbcTemplate, caused a slow memory leak that gave us OutOfMemoryError after about 12 hours of live traffic.
We are using 3.0.1.RELEASE but from Fisheye it looks like this behaviour is still present in your trunk.
The following seem like options, please do as you see fit:
a) Update the Javadoc with a warning about this behaviour
b) Limit the max size of the Map, configurable but with sensible defaults
c) use a WeakReference or SoftReference HashMap
Our workaround has been to extend the class and override the method as follows:
Andrew Robinson opened SPR-7237 and commented
org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate has the potential to leak memory via its parsedSqlCache property.
The code only ever adds to the Map and does not limit its size in any way.
Nothing in the Javadoc makes developers aware that this Map could potentially grow without bounds.
We encountered this problem only under live load. The search on our website has the potential to generate a large number of permutations. We were thus dynamically generating a large number of unique SQL statements.
We do use bind params where possible but there are places where this is difficult or inconvenient.
The size of these statements as String keys, stored within NamedParameterJdbcTemplate, caused a slow memory leak that gave us OutOfMemoryError after about 12 hours of live traffic.
We are using 3.0.1.RELEASE but from Fisheye it looks like this behaviour is still present in your trunk.
The following seem like options, please do as you see fit:
a) Update the Javadoc with a warning about this behaviour
b) Limit the max size of the Map, configurable but with sensible defaults
c) use a WeakReference or SoftReference HashMap
Our workaround has been to extend the class and override the method as follows:
Affects: 3.0.1
Referenced from: commits 2136b04
The text was updated successfully, but these errors were encountered: