Function remove threaded list

1

Algorithm remove_first(L):
    if L.head is None then
        Indicate an error: the list is empty.
    L.head = L.head.next 
    L.size = L.size−1 

I was left with doubt about memory leak. Since the removal of nodes seems to work only with an exchange of pointers, I was doubtful if the memory, with this exchange, is allocated and inaccessible or not, if the exchange already makes the memory available? I thought of the free function of C, is there any analog method in python to make memory available? If the case.

    
asked by anonymous 14.10.2017 / 02:44

1 answer

1

This question has already been answered in the English OS.

Python uses garbage collector for memory control. Thus, in time gc clears memory by releasing objects that are not referenced.

So, using the command del you can mark the object as "deletable" and gc will at some point release the memory used by this object.

Source:

How can I explicitly free memory in Python?

Official Documentation

    
16.10.2017 / 16:37