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.
You have a hot loop that processes tens of millions of fixed-size records and spends most of its time on CPU, not I/O. If algorithmic complexity cannot change, what measurements and code changes would you consider to improve throughput?
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?
A binary file format is being parsed by the same C++ code on x86 servers and ARM-based test machines. One test only fails on ARM after someone rewrote the parser to cast a byte buffer directly to a struct. What would you inspect, and how would you make the parser safe across platforms?
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?
A parser builds a heap-allocated char ** list of tokens and hands it to the caller. Some tokens are duplicated strings, and some are slices into a larger buffer. How would you design the ownership rules and cleanup path so the caller can safely filter or free the result without leaks or double frees?
Unlock Full Question Bank
Get access to all 20 Language-Level Memory Management (C/C++/Rust) interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.