I have a chunk of python code that processes each element from a list, and then appends the processed element to another list:
unprocessed_list = [1,2,3,4,5,6,7,8,9,10]
processed_list = []
while len(l1) > 0:
processed_list.append(process_element(l1[0]))
del unprocessed_list[0]
print "Unprocessed size:" ,sys.getsizeof(unprocessed_list)
print "Processed size:" ,sys.getsizeof(processed_list)
I have re-written the code so that after an element is processed, it gets deleted with the del
statement, and I see in the output that the unprocessed_list
shrinks in size as the processed_list
grows.
Does this mean that actual memory will be released, or do I need to do something additionally? Can/should I run the garbage collection manually?
This runs in python 2.7