Python uses two strategies for memory allocation- Reference counting and Automatic garbage collection:
Reference Counting: works by counting the number of times an object is referenced by other objects in the system. When an object'* reference count reaches zero, Python collects it automatically.
Automatic Garbage Collection: Python schedules garbage collection based upon a threshold of object allocations and object de-allocations. When the number of allocations minus the number of deallocations are greater than the threshold number, the garbage collector is run and the unused block of memory is reclaimed.