diff --git a/RELEASES.md b/RELEASES.md index 284b18aa..b355367d 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -24,6 +24,11 @@ Linker ------ - Remove exception for input map dependency processing (now that compiler no longer emits such a dependency). +- Reduce peak memory usage by clearing buffer of `xmlo` reader between + events. + - How effective this is varies depending on the size of individual + entities within the XML document. In some cases, it can reduce peak + memory usage by half. v18.0.3 (2021-07-21) diff --git a/tamer/src/obj/xmlo/reader/mod.rs b/tamer/src/obj/xmlo/reader/mod.rs index 9b24477c..318bfc8c 100644 --- a/tamer/src/obj/xmlo/reader/mod.rs +++ b/tamer/src/obj/xmlo/reader/mod.rs @@ -250,6 +250,11 @@ where /// /// TODO: Augment failures with context pub fn read_event<'a>(&mut self) -> XmloResult> { + // Just to cut down on peak memory usage, cleaning up after a + // previous run. This does not affect behavior. + self.buffer.clear(); + self.sub_buffer.clear(); + let event = self.reader.read_event(&mut self.buffer)?; // Ensure that the first encountered node is something we expect