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.

HardSystem Design
132 practiced

Design a bounded queue in C++ for one producer thread and one consumer thread on the same machine, where millions of handoffs per second are expected and latency matters more than perfect generality. What invariants would your design need to preserve, and what synchronization and memory-safety issues would you pay closest attention to?

MediumTechnical
68 practiced

A library function allocates a buffer, returns it to the caller, and another layer later frees it. After a refactor, some paths free the buffer twice and other paths leak it. How would you redesign the interface contract so ownership is obvious and hard to misuse?

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.

HardTechnical
84 practiced

You are designing a C event-loop API that stores a callback and a user-data pointer for later invocation. The callback may run long after registration, and callers can unregister at any time. What rules or safeguards would you put in place so the callback does not dereference freed memory?

MediumTechnical
78 practiced

A request-handling thread needs to read and update a small shared state object on every request. A mutex keeps the code simple, but latency is too high under load. How would you decide whether to keep the lock, change the data layout, or use a different synchronization strategy?

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.