public void endDocument() throws IOException {
        while (depth > 0) {
            endTag(elementStack[depth * 3 - 3], elementStack[depth * 3 - 1]);
        }
        flush();
    }
size (in characters) for the write buffer
main/thirdparty/cgeo/org/kxml2/io/KXmlSerializer.java