#NEWLINE# def trace_memory_usage( self , frame , event , arg ) : #NEWLINE# #INDENT# 'Callback for sys.settrace' #NEWLINE# if ( frame . f_code in self . code_map ) : #NEWLINE# #INDENT# if ( event == 'call' ) : #NEWLINE# #INDENT# self . prevlines . append ( frame . f_lineno ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( event == 'line' ) : #NEWLINE# #INDENT# self . code_map . trace ( frame . f_code , self . prevlines [ ( - 1 ) ] ) #NEWLINE# self . prevlines [ ( - 1 ) ] = arg . f_lineno #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( event == 'return' ) : #NEWLINE# #INDENT# self . code_map . trace ( frame . f_code , self . prevlines . pop ( ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# if ( self . _original_trace_function is not None ) : #NEWLINE# #INDENT# self . _original_trace_function ( frame , event , arg ) #NEWLINE# #UNINDENT# return self . trace_memory_usage