InterviewStack.io LogoInterviewStack.io

Garbage Collected Memory Management Questions

Covers memory management in managed runtimes that use garbage collection. Topics include the memory model distinguishing value types and reference types, stack and heap allocation patterns, how common garbage collection algorithms work and their runtime impacts such as pause times and allocation throughput, causes of allocation pressure, and strategies to reduce garbage collection overhead. Practical techniques include avoiding boxing, reusing and preallocating collections, using value types or structs for small frequently instantiated data, object pooling, and data oriented design trade offs versus object oriented design for performance. Candidates should also know profiling tools, memory budgeting for constrained platforms such as mobile or game consoles, and platform specific considerations for engines like Unity.

EasyTechnical
0 practiced
List common causes of allocation pressure in data-science workloads and give a short example for each (e.g., temporary Python lists in map operations, expensive eager copies in NumPy, frequent small object creation, excessive string concatenation). How would you detect which of these is dominant in a job?
MediumTechnical
0 practiced
Write a short Python example that creates a reference cycle preventing GC (e.g., two objects referencing each other and defining __del__), then show how to fix it so CPython's garbage collector can reclaim them. Explain why __del__ complicates cycle collection.
MediumTechnical
0 practiced
Describe how TensorFlow and PyTorch manage CPU and GPU memory differently. For GPU, explain common causes of high memory usage and practical mitigations such as mixed precision training, gradient checkpointing, reducing batch size, moving tensors to CPU, and memory pinning. Mention commands/APIs to inspect GPU memory usage.
EasyTechnical
0 practiced
You need to compute the mean of a numeric column from a very large CSV (dozens of GB) without loading the full file into memory. In Python, describe a memory-efficient implementation (pseudocode or explanation). Specify libraries or APIs you'd use (e.g., pandas chunksize, csv.reader, generators) and any numerical stability concerns for streaming aggregation.
HardTechnical
0 practiced
A streaming aggregator currently creates a new dict for each event and is GC-bound. Propose algorithmic alternatives and data structures that reduce allocation rate (e.g., reuse dicts, use typed arrays or structs, use ring buffers, or compact keys into integers). Discuss time/space trade-offs and how GC behavior changes.

Unlock Full Question Bank

Get access to hundreds of Garbage Collected Memory Management interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.