cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "mr.abanjo" <>
Subject Some doubts about DataContext and memory allocation
Date Sat, 22 May 2010 09:03:10 GMT
I'm developing a simple web application that store in a table an user
When a new user comes, i save a new record to a database using datacontext:

Cayenne perform an insert and all works fine.
I have 2 questions:

1) Reading the documentation the right way in a web application to create a
datacontext is per session:
What happens if i treat it as a singleton? ( So i have one instance for all
the users )

2) My web application has a high traffic, so i think that in a few time i've
"registered" in datacontext  thousands of record. This objects are correctly
garbage collected or they stay in memory?
Reading the documentation:

Since Cayenne 3.0, by default DataContext uses weak references to store
registered objects. So objects are allowed to be garbage collected by the VM
if they are not referenced elsewhere in the application. "Elsewhere" usually
means one of the following:

   - An object is directly or indirectly referenced by the application. [*NO
   reference to them by any object in my application]*
   - An object is a part of the cached query result stored by Cayenne. [*I
   never configured cayenne for cache.. so if i'm not wrong, the default is
   - An object is "dirty" (i.e. new, modified or deleted). In this case
   Cayenne ensures that such object is retained at least until commit or
   rollback. [*I perform always a commit after registering a new object]*

So... i think that the memory should be correctly freed.

N.B. I'm using Cayenne 3.0!

Thanks for help!

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message