memory - Printing whenever a python object is freed? -
i assure several numpy arrays i'm allocating freed.
i'm curious there module allow me track object , print whenever memory de-allocated.
for context i'm asking question because when reach point in programme scheme monitor shows python using 300ishmb. execute 2 commands: first creates list of numpy arrays comes 1gb in size. next command performs vstack on list farther increases memory 1gb. take big numpy array, math reply 1mb (8000 x 128 uint8 ndarray). other arrays no longer needed, should unallocated @ end of function. however, after homecoming function , collect garbage i'm still left python using 1gb of memory. did 700mb come from!?
i'll farther illustrate illustration sudo-code
def myfunc(api): # gets list of 1000 1mb arrays list_ = api.get_arrays() # stacks big 1gb array bigarray = np.vstack(list_) # summarizes big array using 1mb smallarray = api.cluster(bigarray) # shouldn't need del statements del list_ del bigarray homecoming smallarray def main(): # preprocessing stuff , have 300mb in memory # costs 2gb run function, should freed @ end smallarray = myfunc(api) # there 700mb of memory allocated! did come from!?
to debug thinking useful ensure numpy arrays gone. maybe has improve idea, @ to the lowest degree has idea.
python memory memory-management numpy
No comments:
Post a Comment