From 44bf1c0b678debcbd3066ca392a8bb08af54a4d8 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Wed, 5 Feb 2020 20:50:53 +0100 Subject: [PATCH] Release statement source upon Effective Model completion Once we have an effective model, we do not need to access statement source, hence we can let it be GC'd. JIRA: YANGTOOLS-652 Change-Id: I5c7024c4709a7b97bf061cd5f02d923319378011 Signed-off-by: Robert Varga --- .../parser/stmt/reactor/SourceSpecificContext.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/yang/yang-parser-reactor/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/SourceSpecificContext.java b/yang/yang-parser-reactor/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/SourceSpecificContext.java index c6c51f301a..59d7be7495 100644 --- a/yang/yang-parser-reactor/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/SourceSpecificContext.java +++ b/yang/yang-parser-reactor/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/SourceSpecificContext.java @@ -76,7 +76,9 @@ public class SourceSpecificContext implements NamespaceStorageNode, NamespaceBeh private final QNameToStatementDefinitionMap qnameToStmtDefMap = new QNameToStatementDefinitionMap(); private final PrefixToModuleMap prefixToModuleMap = new PrefixToModuleMap(); private final BuildGlobalContext currentContext; - private final StatementStreamSource source; + + // Freed as soon as we complete ModelProcessingPhase.EFFECTIVE_MODEL + private StatementStreamSource source; /* * "imported" namespaces in this source -- this points to RootStatementContexts of @@ -307,8 +309,12 @@ public class SourceSpecificContext implements NamespaceStorageNode, NamespaceBeh if (phaseCompleted && currentPhaseModifiers.isEmpty()) { finishedPhase = phase; LOG.debug("Source {} finished phase {}", source, phase); + if (phase == ModelProcessingPhase.EFFECTIVE_MODEL) { + // We have the effective model acquired, which is the final phase of source interaction. + LOG.trace("Releasing source {}", source); + source = null; + } return PhaseCompletionProgress.FINISHED; - } return hasProgressed ? PhaseCompletionProgress.PROGRESS : PhaseCompletionProgress.NO_PROGRESS; -- 2.36.6