summaryrefslogtreecommitdiffstats
path: root/infra/data-impl/src/main/java/io/fd
diff options
context:
space:
mode:
authorMarek Gradzki <mgradzki@cisco.com>2017-09-08 08:16:55 +0200
committerJan Srnicek <jsrnicek@cisco.com>2017-09-13 08:08:10 +0000
commita628f8faaeecf3e4ba957f7561ca4937ba7acc6b (patch)
treeb6e08e420a00e229bd7929cdac02965af41bb00b /infra/data-impl/src/main/java/io/fd
parentdbc30d321bd385e5cd5bce1e6f567ade9ca1aa25 (diff)
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 <mgradzki@cisco.com>
Diffstat (limited to 'infra/data-impl/src/main/java/io/fd')
-rw-r--r--infra/data-impl/src/main/java/io/fd/honeycomb/data/impl/ReadableDataTreeDelegator.java10
1 files 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<? extends DataObject> dataObject;
+ final Optional<? extends DataObject> 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.<NormalizedNode<?, ?>>fromNullable(value);
@@ -152,6 +154,10 @@ public final class ReadableDataTreeDelegator implements ReadableDataManager {
final Multimap<InstanceIdentifier<? extends DataObject>, ? 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<? extends DataObject> instanceIdentifier : dataObjects.keySet()) {
final YangInstanceIdentifier rootElementId = serializer.toYangInstanceIdentifier(instanceIdentifier);
final NormalizedNode<?, ?> node =