Sobes.tech
Middle

How was the process of documentation management and storage organized in your previous team? How does memory management work in Python and what is a garbage collector?

sobes.tech AI

Answer from AI

In my previous team, documentation was maintained in a centralized repository, usually in Markdown or Confluence format. Each module or component had its own folder with documentation describing architecture, API, installation, and usage instructions. Documentation updates were made in parallel with code changes, allowing it to stay current.

In Python, memory management is based on reference counting and garbage collection. Each object in Python has a reference count — when a reference to the object is created, the count increases; when a reference is deleted, it decreases. When the count reaches zero, the object's memory is freed.

However, due to cyclic references (when objects refer to each other), reference counting alone cannot always free memory. Python includes a garbage collector that periodically searches for and frees cyclic references.

Example:

import gc

# Enable garbage collector
gc.enable()

# Create a cyclic reference
class A:
    def __init__(self):
        self.ref = None

obj1 = A()
obj2 = A()
obj1.ref = obj2
obj2.ref = obj1

# Delete references
del obj1
del obj2

# Garbage collector will free memory despite cycles
gc.collect()