def trace_memory_usage(self, frame, event, arg):
        """Callback for sys.settrace"""
        if event in ('line', 'return') and frame.f_code in self.code_map:
                lineno = frame.f_lineno
                if event == 'return':
                    lineno += 1
                entry = self.code_map[frame.f_code].setdefault(lineno, [])
                entry.append(_get_memory(os.getpid()))

        return self.trace_memory_usage
def trace_memory_usage ( self , frame , event , arg ) : if event in ( 'line' , 'return' ) and frame . f_code in self . code_map : lineno = frame . f_lineno if event == 'return' : lineno += 1 entry = self . code_map [ frame . f_code ] . setdefault ( lineno , [ ] ) entry . append ( _get_memory ( os . getpid ( ) ) ) return self . trace_memory_usage
Callback for sys.settrace