1#!/usr/bin/python -u
2import sys
3import libxml2
4try:
5    import StringIO
6    str_io = StringIO.StringIO
7except:
8    import io
9    str_io = io.StringIO
10
11# Memory debug specific
12libxml2.debugMemory(1)
13
14i = 0
15while i < 5000:
16    f = str_io("foobar")
17    buf = libxml2.inputBuffer(f)
18    i = i + 1
19
20del f
21del buf
22
23# Memory debug specific
24libxml2.cleanupParser()
25if libxml2.debugMemory(1) == 0:
26    print("OK")
27else:
28    print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
29    libxml2.dumpMemory()
30
31