diff --git a/cbits/hslibxml-shim.c b/cbits/hslibxml-shim.c
--- a/cbits/hslibxml-shim.c
+++ b/cbits/hslibxml-shim.c
@@ -4,6 +4,10 @@
 #include <string.h>
 #include <stdio.h>
 
+/* for hslibxml_parse_complete */
+#include <libxml/parserInternals.h>
+
+
 typedef struct UserData UserData;
 struct UserData
 {
@@ -52,6 +56,27 @@
 hslibxml_free_parser(xmlParserCtxt *ctx)
 {
 	xmlFreeParserCtxt(ctx);
+}
+
+int
+hslibxml_parse_complete(xmlParserCtxt *ctx) {
+	xmlParserInputPtr input;
+	int rc;
+	
+	rc = xmlParseChunk(ctx, NULL, 0, 1);
+	
+	/* Optimization: delete input stream buffers when there's nothing
+	 * more to be parsed.
+	 *
+	 * These buffers can be quite large, so if they are retained until the
+	 * Haskell garbage collector runs hslibxml_free_parser, then memory
+	 * use might become very large when parsing many documents in a loop.
+	 */
+	while ((input = inputPop(ctx)) != NULL) {
+		xmlFreeInputStream(input);
+	}
+	
+	return rc;
 }
 
 int
diff --git a/cbits/hslibxml-shim.h b/cbits/hslibxml-shim.h
--- a/cbits/hslibxml-shim.h
+++ b/cbits/hslibxml-shim.h
@@ -13,6 +13,9 @@
 hslibxml_free_parser(xmlParserCtxt *ctx);
 
 int
+hslibxml_parse_complete(xmlParserCtxt *ctx);
+
+int
 hslibxml_want_callback(xmlParserCtxt *ctx, void *cb_ctx);
 
 internalSubsetSAXFunc
diff --git a/lib/Text/XML/LibXML/SAX.hs b/lib/Text/XML/LibXML/SAX.hs
--- a/lib/Text/XML/LibXML/SAX.hs
+++ b/lib/Text/XML/LibXML/SAX.hs
@@ -132,7 +132,7 @@
 -- closed correctly.
 -- 
 parseComplete :: Parser m -> m ()
-parseComplete p = parseImpl p (\h -> cParseChunk h nullPtr 0 1)
+parseComplete p = parseImpl p (\h -> cParseComplete h)
 
 -- Callbacks {{{
 
@@ -634,6 +634,9 @@
 
 foreign import ccall safe "libxml/parser.h xmlParseChunk"
 	cParseChunk :: Ptr Context -> CString -> CInt -> CInt -> IO CInt
+
+foreign import ccall safe "hslibxml-shim.h hslibxml_parse_complete"
+	cParseComplete :: Ptr Context -> IO CInt
 
 foreign import ccall safe "libxml/parser.h xmlStopParser"
 	cStopParser :: Ptr Context -> IO ()
diff --git a/libxml-sax.cabal b/libxml-sax.cabal
--- a/libxml-sax.cabal
+++ b/libxml-sax.cabal
@@ -1,5 +1,5 @@
 name: libxml-sax
-version: 0.7.3
+version: 0.7.4
 license: MIT
 license-file: license.txt
 author: John Millikin
@@ -25,7 +25,7 @@
 source-repository this
   type: bazaar
   location: https://john-millikin.com/branches/haskell-libxml-sax/0.7/
-  tag: haskell-libxml-sax_0.7.3
+  tag: haskell-libxml-sax_0.7.4
 
 library
   hs-source-dirs: lib
