Well, from the code snip you provided, this is quiet obvious why such
behavior occurs - creating a new ServletConfiguration on every request
basically reinitializes the whole Cayenne access stack, including
connections, re-reading DataMaps, etc. Never do that unless you really
have a reason. Rather rewrite ''getNewCayenneDataContext" to just
return DataContext.createDataContext().
And even creating a new DataContext on every request is extra overhead
and kills all the caching benefits, but I remember you mentioned
something about loading too many objects in memory, and a need to do
cleanup every once in while (though there are probably other ways
around too)
Andrus
On Sunday, May 4, 2003, at 08:53 AM, martin ruff wrote:
> Hi I've got a wep application,
> I have a menu point to show the user a overview of some kind
> the code that is executed when the user clicks the button creates a
> new datacontext (resetReusedCayenneDataContext(..) is called when the
> user clicks):
> public static DataContext getNewCayenneDataContext(ServletContext
> theContext)
> {
> ServletConfiguration conf = new ServletConfiguration();
> conf.setServletContext(theContext);
> Configuration.initSharedConfig(conf);
> return conf.getDomain().createDataContext();
> }
>
> public static void resetReusedCayenneDataContext(HttpServletRequest
> request)
> {
> request.getSession().setAttribute(DATA_CONTEXT_KEY,
> getNewCayenneDataContext(request));
> }
>
> If now, I click very often, the I get:
> WARN RuntimeLoadDelegate: Started configuration loading.
> WARN RuntimeLoadDelegate: loaded domain: Reporting
> WARN RuntimeLoadDelegate: loaded <map name='datamap'
> location='datamap.map.xml'>.
> WARN RuntimeLoadDelegate: loading <node name='datanode'
> datasource='datanode.driver.xml'
> factory='org.objectstyle.cayenne.conf.DriverDataSourceFactory'>.
> WARN RuntimeLoadDelegate: using factory:
> org.objectstyle.cayenne.conf.DriverDataSourceFactory
> WARN DriverDataSourceFactory: loading driver information from
> (datanode.driver.xml).
> WARN DriverDataSourceFactory: location found in filesystem.
> WARN DriverDataSourceFactory: loading driver org.postgresql.Driver
> WARN DriverDataSourceFactory: loading user name and password.
> WARN QueryLogger: Connecting. DataSource information:
>
This archive was generated by hypermail 2.0.0 : Sun May 04 2003 - 11:50:05 EDT