InterviewStack.io LogoInterviewStack.io

Language-Level Memory Management (C/C++/Rust) Questions

How specific languages expose and manage memory: pointers and references, pointer arithmetic, stack versus heap allocation, ownership and borrowing in Rust, RAII and smart pointers in C++, manual allocation and freeing in C, and garbage-collection semantics as a language feature. Covers reasoning about ownership, lifetimes, leaks, and dangling references at the language level. OS-level virtual memory and paging internals live in Operating Systems & Systems Programming.

MediumTechnical
61 practiced

A teammate replaced a byte-by-byte read with a cast from uint8_t * to uint32_t * to speed up parsing. The code passes unit tests on one platform but breaks under optimization on another. What concerns would you raise, and how would you prove whether the cast is safe or whether the optimization is relying on undefined behavior?

EasyTechnical
132 practiced

A C function in a service occasionally crashes when a caller uses the pointer it returns, but only after the function has finished executing. How would you debug this, and what would you look for in the code and runtime behavior to confirm the root cause?

MediumTechnical
62 practiced

A multithreaded worker becomes slower as you add more CPU cores, even though each thread mostly updates its own counter inside a shared status object. How would you investigate the slowdown, and what low-level effects might explain it?

MediumTechnical
62 practiced

Write a C function that removes every node with a target value from a singly linked list and returns the new head. The implementation should free removed nodes correctly and handle deleting the first node without special-case bugs.

MediumTechnical
67 practiced

A long-running service suddenly shows a large memory spike right after it forks a worker process, even though the child does very little work. What does the OS do in this situation, and what would you inspect to tell whether the spike is expected or a real problem?

Unlock Full Question Bank

Get access to all 20 Language-Level Memory Management (C/C++/Rust) interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.