|
Re: [CDO] Caching and explicit garbage collection [message #1799487 is a reply to message #1799463] |
Fri, 07 December 2018 16:16 |
|
The CDOView caches CDOObjects, wich are generally small and cheap. The CDOSession caches CDORevisions, which are often big and expensive. Both caches are soft caches by default (the type of the revision cache can not be changed). That means, they try to keep their elements as long as possible. I'm not sure that an explicit call to gc() is supposed to impact the cache contents. But as soon as heap space is needed AND free heap space is not sufficient AND cache contents are reclaimable (i.e., ONLY softly referenced), then those cache contents should be garbage-collected. If you're saying that that's not the case for you then you must have seen an OutOfMemoryError. Right?
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
|
|
|
|
Re: [CDO] Caching and explicit garbage collection [message #1800853 is a reply to message #1800146] |
Wed, 09 January 2019 06:42 |
|
I doubt that you could do better than a garbage collector. Perhaps you could try a different one? I have absolutely no experience with that, though.
There's also code at the beginning of CDOSessionImpl.refresh(Provider), which you could try to mimic:
Map<CDOBranch, List<InternalCDOView>> views = new HashMap<CDOBranch, List<InternalCDOView>>();
Map<CDOBranch, Map<CDOID, InternalCDORevision>> viewedRevisions = new HashMap<CDOBranch, Map<CDOID, InternalCDORevision>>();
collectViewedRevisions(views, viewedRevisions);
cleanupRevisionCache(viewedRevisions);
And:
private void collectViewedRevisions(Map<CDOBranch, List<InternalCDOView>> views, Map<CDOBranch, Map<CDOID, InternalCDORevision>> viewedRevisions)
{
for (InternalCDOView view : getViews())
{
if (view.getTimeStamp() == CDOView.UNSPECIFIED_DATE)
{
CDOBranch branch = view.getBranch();
Map<CDOID, InternalCDORevision> revisions = viewedRevisions.get(branch);
boolean needNewMap = revisions == null;
if (needNewMap)
{
revisions = CDOIDUtil.createMap();
}
view.collectViewedRevisions(revisions);
if (!revisions.isEmpty())
{
List<InternalCDOView> list = views.get(branch);
if (list == null)
{
list = new ArrayList<InternalCDOView>();
views.put(branch, list);
}
list.add(view);
if (needNewMap)
{
viewedRevisions.put(branch, revisions);
}
}
}
}
}
private void cleanupRevisionCache(Map<CDOBranch, Map<CDOID, InternalCDORevision>> viewedRevisions)
{
Set<InternalCDORevision> set = new HashSet<InternalCDORevision>();
for (Map<CDOID, InternalCDORevision> revisions : viewedRevisions.values())
{
for (InternalCDORevision revision : revisions.values())
{
set.add(revision);
}
}
InternalCDORevisionCache cache = getRevisionManager().getCache();
List<CDORevision> currentRevisions = cache.getCurrentRevisions();
for (CDORevision revision : currentRevisions)
{
if (!set.contains(revision))
{
cache.removeRevision(revision.getID(), revision);
}
}
}
It's important to NOT remove a revision from the cache if it is currently being referenced from at least one EObject in at least one CDOView. This restriction may not apply if you can guarantee that no user is committing changes to the repository. In that case you could even try to configure a dummy revision cache in your session:
IConnector connector = Net4jUtil.getConnector(container, connectorType, connectorDescription);
CDONet4jSessionConfiguration config = CDONet4jUtil.createNet4jSessionConfiguration();
config.setConnector(connector);
config.setRepositoryName(repositoryName);
config.setRevisionManager(CDORevisionUtil.createRevisionManager(CDORevisionCache.NOOP));
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
|
|
|
Powered by
FUDForum. Page generated in 0.24868 seconds