jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thomas Mueller (JIRA)" <j...@apache.org>
Subject [jira] Commented: (JCR-1216) Unreferenced sessions should get garbage collected
Date Fri, 25 Jul 2008 16:35:32 GMT

    [ https://issues.apache.org/jira/browse/JCR-1216?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12616938#action_12616938

Thomas Mueller commented on JCR-1216:

Another idea is: Split SessionImpl into a 'end user class' and an 'core class' to allow garbage

class SessionImpl implements Session {
    private InternalJackrabbitSession session;
    private Exception openStackTrace;
    SessionImpl(..) {
        session = ...
        openStackTrace = new Exception("Stack Trace");

    public void finalize() {
        if (!closed) {
            LOG.error("Session not closed", openStackTrace);


class SessionCore implements InternalJackrabbitSession {
    ... basically what is now SessionImpl ...

Only SessionCore would be kept in the map, not SessionImpl. The InternalJackrabbitSession
interface would be simpler than the Session interface. There could be multiple InternalJackrabbitSession
implementations (a embedded implementation, a client-server implementation, a clustering implementation).

This split of 'user facing session' and 'internal session' is probably what we want to achieve
with the 'Jackrabbit SPI' as well.

> Unreferenced sessions should get garbage collected
> --------------------------------------------------
>                 Key: JCR-1216
>                 URL: https://issues.apache.org/jira/browse/JCR-1216
>             Project: Jackrabbit
>          Issue Type: Improvement
>          Components: jackrabbit-core
>            Reporter: Thomas Mueller
> If an application opens many sessions and doesn't close them, they are never garbage
collected. After some time, the virtual machine will run out of memory. This code will run
out of memory after a few thousand logins:
> Repository rep = new TransientRepository();
> for (int i = 0; ; i++) {
>   rep.login(new SimpleCredentials("", new char[0]));
> }
> Using a finalizer to close SessionImpl doesn't work, because it seems there are references
from the (hard referenced part of the cache) to the SessionImpl objects. Maybe it is possible
to remove those references, or change them to weak references.

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message