[ create a new paste ] login | about

Link: http://codepad.org/F23cwezb    [ raw code | fork ]

greg - Python, pasted on Jun 26:
import sys
import gc

try:
    import win32process
except:
    win32process = None

def foo(s):
    d = range(100000)
    try:
        raise Exception()
    except:
        # Line 1: uncomment to show collector leaving memory
        s.e = sys.exc_info()
        pass

def bar():
    s = O()
    foo(s)

class O(object): pass

for x in xrange(100000):
    for y in xrange(100):
        bar()
    # Line 2: uncomment to show collector only collecting half
    #gc.collect()
    if win32process:
        proc = win32process.GetCurrentProcess()
        r = win32process.GetProcessMemoryInfo(proc)
        print r['WorkingSetSize']
 	  	 


Create a new paste based on this one


Comments: