From a628f8faaeecf3e4ba957f7561ca4937ba7acc6b Mon Sep 17 00:00:00 2001 From: Marek Gradzki Date: Fri, 8 Sep 2017 08:16:55 +0200 Subject: Make data stored in ModificationCache eligible for GC earlier ModificationCache might store huge amount of data. After DOs are retreved from readers it is not used anymore. Change-Id: I66d57047212fed02321c416af3608c4998315ce7 Signed-off-by: Marek Gradzki --- .../io/fd/honeycomb/data/impl/ReadableDataTreeDelegator.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/infra/data-impl/src/main/java/io/fd/honeycomb/data/impl/ReadableDataTreeDelegator.java b/infra/data-impl/src/main/java/io/fd/honeycomb/data/impl/ReadableDataTreeDelegator.java index a7ad88c9f..7c46b4ca4 100644 --- a/infra/data-impl/src/main/java/io/fd/honeycomb/data/impl/ReadableDataTreeDelegator.java +++ b/infra/data-impl/src/main/java/io/fd/honeycomb/data/impl/ReadableDataTreeDelegator.java @@ -131,9 +131,11 @@ public final class ReadableDataTreeDelegator implements ReadableDataManager { checkNotNull(path, "Invalid instance identifier %s. Cannot create BA equivalent.", yangInstanceIdentifier); LOG.debug("OperationalDataTree.readNode(), path={}", path); - final Optional dataObject; + final Optional dataObject = readerRegistry.read(path, ctx); + + // Modification cache should not be used after DOs are read, so we can clear it now to reduce peak footprint. + ctx.getModificationCache().close(); - dataObject = readerRegistry.read(path, ctx); if (dataObject.isPresent()) { final NormalizedNode value = toNormalizedNodeFunction(path).apply(dataObject.get()); return Optional.>fromNullable(value); @@ -152,6 +154,10 @@ public final class ReadableDataTreeDelegator implements ReadableDataManager { final Multimap, ? extends DataObject> dataObjects = readerRegistry.readAll(ctx); + // Modification cache should not be used after DOs are read, so we can clear it now to reduce peak footprint. + // Even greater reduction can be achieved with HONEYCOMB-361. + ctx.getModificationCache().close(); + for (final InstanceIdentifier instanceIdentifier : dataObjects.keySet()) { final YangInstanceIdentifier rootElementId = serializer.toYangInstanceIdentifier(instanceIdentifier); final NormalizedNode node = -- cgit 1.2.3-korg