xmlParseCharDataComplex never shrinks the input buffer
See discussion in #192 (closed).
Simple fix: nwellnhof/libxml2@99bda1e1
But performance-wise, it would be best to shrink the buffer as late as possible. This means to check the actual remaining bytes instead of the crude "every nth iteration" solution. Since we're processing UTF-8, we should shrink and grow if the buffer contains less than four bytes. Ideally, hitting EOF shouldn't trigger additional shrink/grow attempts.
Edited by Nick Wellnhofer