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