Yang Zhou in  
Software Engineer  

Memory Management in Python: 3 Popular Interview Questions

The memory management is one of the most popular interview topics for Python developers. Because questions about it can test a programmer’s understanding of some internal mechanisms of Python.

Some common questions are:

  • How to get the memory address of a Python object (or vice versa)?
  • How does Python collect garbage (useless objects)?
  • How does Python optimise memory usages (interning mechanism)?

Check out this article for more details.

Just a moment...

Just a moment...

medium.com
4
1177
Sort by:
2HUf31o07hUGBackend Software Engineer  
For everyone's reference, garbage collection is implemented in Python in two ways- reference counting and generational. The garbage collector is keeping track of all objects in the memory. 1) When the reference count of an object reaches 0, reference counting garbage collection algorithm cleans up the object immediately. 2) If you have a cycle, reference count doesn’t reach zero, you wait for the generational garbage collection algorithm to run and clean the object.
2

About

Public

Software Engineer

Members

80,046