Whenever Python exits, why isn’t all the memory de-allocated?

  • When Python terminates, some Python modules, particularly those with circular references to other objects or objects referred from global namespaces, are not necessarily destroyed or de-allocated.

  • It is not feasible to de-allocate memory that has been reserved by the C library.

  • Python would try to de-allocate every object on exit since it has its own efficient cleanup mechanism.