inbuf.py 420 B

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