mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-05-19 20:01:53 +00:00
gc debug functions
git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@1195 e7d03fd6-7b0d-0410-9947-9c21f3af8025
This commit is contained in:
parent
a5eea7e08c
commit
c62de8c0d5
1 changed files with 23 additions and 0 deletions
|
|
@ -41,11 +41,34 @@ def _text (*args, **kwargs):
|
|||
text = " ".join(map(str, args))
|
||||
print >>sys.stderr, colorize(text, color=kwargs.get('color'))
|
||||
|
||||
# memory leak debugging
|
||||
#import gc, os
|
||||
#gc.set_debug(gc.DEBUG_LEAK)
|
||||
|
||||
# debug function, using the debug level
|
||||
def debug (level, *args):
|
||||
#_text("collected %d"%gc.collect())
|
||||
#_text("objects %d"%len(gc.get_objects()))
|
||||
#_text("garbage %d"%len(gc.garbage))
|
||||
#if gc.garbage:
|
||||
# for o in gc.garbage:
|
||||
# _text("O %s"%repr(o))
|
||||
#_text("Mem: %s"%usedmemory())
|
||||
if level <= _debuglevel:
|
||||
_text(*args)
|
||||
|
||||
def usedmemory ():
|
||||
pid = os.getpid()
|
||||
fp = file('/proc/%d/status'%pid)
|
||||
try:
|
||||
for line in fp.readlines():
|
||||
if line.startswith('VmRSS:'):
|
||||
return line[6:].strip()
|
||||
finally:
|
||||
fp.close()
|
||||
return val
|
||||
|
||||
|
||||
def info (*args):
|
||||
args = list(args)
|
||||
args.insert(0, "info:")
|
||||
|
|
|
|||
Loading…
Reference in a new issue