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