From 1bc86e4d7c41c8e637b408ae7307e351208692ab Mon Sep 17 00:00:00 2001 From: Rikard Pavelic Date: Sun, 7 Apr 2019 17:22:03 +0200 Subject: [PATCH] Lazy allocate NamespaceMappings This greatly reduces the memory usage while doing transform to output stream. --- src/org/apache/xalan/xsltc/trax/DOM2TO.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/org/apache/xalan/xsltc/trax/DOM2TO.java b/src/org/apache/xalan/xsltc/trax/DOM2TO.java index 705dc34fa..dd52b1293 100644 --- a/src/org/apache/xalan/xsltc/trax/DOM2TO.java +++ b/src/org/apache/xalan/xsltc/trax/DOM2TO.java @@ -160,7 +160,7 @@ private void parse(Node node) } // Process all non-namespace attributes next - NamespaceMappings nm = new NamespaceMappings(); + NamespaceMappings nm = null; for (int i = 0; i < length; i++) { final Node attr = map.item(i); final String qnameAttr = attr.getNodeName(); @@ -176,6 +176,7 @@ private void parse(Node node) // For attributes not given an prefix explictly // but having a namespace uri we need // to explicitly generate the prefix + if (nm == null) nm = new NamespaceMappings(); String newPrefix = nm.lookupPrefix(uriAttr); if (newPrefix == null) newPrefix = nm.generateNextPrefix();