home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / share / doc / python-libxml2 / examples / inbuf.py < prev    next >
Encoding:
Python Source  |  2002-09-12  |  420 b   |  26 lines

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