Vidage automatique du cache hibernate
Bonjour, Nous avons trouvé dans une application utilisant topia une fuite mémoire due au cache hibernate. En effet, comme le confirme la documentation [1], il n'est pas libéré tant que la session n'est pas close: "The Session caches every object that is in a persistent state (watched and checked for dirty state by Hibernate). If you keep it open for a long time or simply load too much data, it will grow endlessly until you get an OutOfMemoryException. One solution is to call clear() and evict() to manage the Session cache, but you should consider a Stored Procedure if you need mass data operations. Some solutions are shown in Chapitre 14, Traitement par lot. Keeping a Session open for the duration of a user session also means a higher probability of stale data." Dans le cas de notre application, il faudrait que après chaque commit, un session.clear() soit fait automatiquement. Le ticket a été créé dans ce but: http://www.nuiton.org/issues/2284 [1] : http://docs.jboss.org/hibernate/orm/3.5/reference/fr-FR/html/transactions.ht... -- Éric Chatellier <chatellier@codelutin.com> Tel: 02.40.50.29.28 http://www.codelutin.com
Le 27/08/2012 17:51, Eric Chatellier a écrit :
Dans le cas de notre application, il faudrait que après chaque commit, un session.clear() soit fait automatiquement. Le ticket a été créé dans ce but: http://www.nuiton.org/issues/2284 À y réfléchir, vider le cache après le commit est notre cas d'utilisation.
Le cache étant alimenté à la lecture ou écriture, le problème serait le même pour un grand nombre de lectures d'une grosse base de données sans aucun commit. L'opération de clear() du cache doit donc peut-être être une opération manuelle. -- Éric Chatellier <chatellier@codelutin.com> Tel: 02.40.50.29.28 http://www.codelutin.com
Le 27/08/2012 17:55, Eric Chatellier a écrit : >> >> L'opération de clear() du cache doit donc peut-être être une >> opération manuelle. Si vous avez un nom de méthode aussi, je suis prenneur car : * topiacontext#clear(boolean) existe déjà : elle supprime la base (h2) * clearCache() ? j'aime pas trop mais ca fait bien ce que ca dit -- Éric Chatellier <chatellier@codelutin.com> Tel: 02.40.50.29.28 http://www.codelutin.com
participants (1)
-
Eric Chatellier