I have a list of large-sized objects. The code below is purely for explanation purposes. self.allocate_memory()
can be implemented accordingly.
class BigObject(object):
def __init__(self, id):
self.id = id
self.allocate_memory(100) # allocates 100 MB of memory to self
BigList = [BigObject(x) for x in range(10000)]
BigList[2] = BigObject(-99) # is this action deleting the memory allocated to BigObject(3)
When I assign a new object to the index in the list, is the memory of object being replaced deallocated? If not, is there a way to ensure this?