[
https://issues.apache.org/jira/browse/JCR-2768?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13962686#comment-13962686
]
ASF GitHub Bot commented on JCR-2768:
-------------------------------------
GitHub user gruberroland-netcentric opened a pull request:
https://github.com/apache/jackrabbit/pull/17
JCR-2768 Replace finalize in SessionImpl with Phantom references
This patch removes the finalize function in SessionImpl. The garbage
collection runs much smoother now.
Tested with 20 threads that open 20000 sessions each and create 50 nodes.
Images are from https://github.com/chewiebug/GCViewer.
Original code:

Patch:

You can merge this pull request into a Git repository by running:
$ git pull https://github.com/gruberroland-netcentric/jackrabbit trunk
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/jackrabbit/pull/17.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #17
----
commit eef4a0cfc861ffc3a559fcd1437742a5a0a2bb63
Author: Roland Gruber <[email protected]>
Date: 2014-04-02T13:29:06Z
JCR-2768 added test to check if logout is called by garbage collection
commit eea7c028854005a4c95d7f1ddb9a1e3bd4280045
Author: gruberroland-netcentric <[email protected]>
Date: 2014-04-07T07:30:17Z
JCR-2768 use ghost references for unclosed session handling
commit cb8cfe6c0cb0af9bad344d48e2c0305208abae48
Author: gruberroland-netcentric <[email protected]>
Date: 2014-04-07T11:36:23Z
JCR-2768 use ghost references for unclosed session handling
commit bd2f48a6ea4de9aa274c978709d2c7db7353e801
Author: gruberroland-netcentric <[email protected]>
Date: 2014-04-07T12:42:18Z
JCR-2768 use ghost references for unclosed session handling
commit 9440ac5ebdbf40aa9bc592b4bd79cbbcd787d8f4
Author: gruberroland-netcentric <[email protected]>
Date: 2014-04-08T06:33:26Z
JCR-2768 throw exception instead of logging
----
> Finalize method on SessionImpl
> ------------------------------
>
> Key: JCR-2768
> URL: https://issues.apache.org/jira/browse/JCR-2768
> Project: Jackrabbit Content Repository
> Issue Type: Improvement
> Components: jackrabbit-core
> Affects Versions: 2.1
> Reporter: Douglas Britsch
>
> Doing some profiling on our application which uses Jackrabbit-2.1.0 I noticed
> that there were an awful lot of java.lang.ref.Finalizer objects hanging
> around. Digging around I found the culprit was a finalize method on
> SessionImpl. While I can see what it is trying to do (close the session if
> you have not called logout) , I have found in the past that on application
> servers, finalize should be avoided for objects that are created and deleted
> frequently, as the GC behavior and object allocation is severely impacted,
> and because of the number of references held by the session this seems like
> it could keep a lot more in memory than needed a lot longer. (for more info
> see http://www.fasterj.com/articles/finalizer1.shtml ).
> Per Jukka's suggestion on the mailing list "
> The automatic closing of a discarded session and related the warning
> message are pretty useful in practice, as there are quite a few
> session leaks in many client applications. So I'd rather keep that
> functionality.
> If the finalizer causes problems, we could investigate using weak (or
> perhaps phantom) references and a reference queue for this purpose.
> The RepositoryImpl class already keeps weak references to all sessions
> in the activeSessions map, so this shouldn't even be too difficult to
> implement."
--
This message was sent by Atlassian JIRA
(v6.2#6252)