Why did C++14 Sized Deallocation (operator delete(void* ptr, std::size_t sz)) yield measurable speedups with modern slab allocators (jemalloc/tcmalloc/mimalloc)?
MULTIPLE CHOICE • ADVANCED • +20 XP
When auditing or writing a compliant custom global C++ void* operator new(std::size_t sz) hook (for telemetry/custom slab), order the mandatory C++ standard rules ([new.delete.single]):
ORDERING • ADVANCED • +20 XP
When sharing an mmap-backed IPC/database file with another process, what fatal hardware/OS signal (NOT SIGSEGV!) kills your C++ process if another writer calls ftruncate to shrink the file underneath pages your reader subsequently accesses?
MULTIPLE CHOICE • ADVANCED • +20 XP
Before C++11 magic statics / std::call_once, why did naive pointer Double-Checked Locking (if (!ptr) { lock(); if (!ptr) ptr = new Singleton(); }) crash intermittently under -O2 or ARM multi-core?
MULTIPLE CHOICE • ADVANCED • +20 XP
Select all the correct techniques for optimizing memory usage in C++ applications.
MULTI SELECT • ADVANCED • +1 XP
Why does glibc ptmalloc allocate tiny allocations cleanly (pushing heap break brk / arena chunks) while routing huge allocations (>= 128 KB+ dynamically tuned M_MMAP_THRESHOLD) directly through mmap()/munmap() ?
MULTIPLE CHOICE • ADVANCED • +20 XP
Why does the C++ standard disallow dereferencing ptr directly AFTER destroying and placement-constructing a new object new (ptr) Entry{newConstId} at the exact same address when Entry declares const int id; (or a reference member)?
MULTIPLE CHOICE • ADVANCED • +20 XP
Consider struct Base { int a; char b; }; (sizeof == 8, 3 trailing tail padding bytes) and struct Derived : Base { char c; };. Why might sizeof(Derived) equal 8 (overlapping c inside Base’s tail padding!) —and why must you NEVER call std::memcpy(&baseRef, &newBase, sizeof(Base)) onto a Base& subobject inside Derived?
MULTIPLE CHOICE • ADVANCED • +20 XP
In a 10 GB database buffer pool or ML matrix cache performing random pointer/lookup sweeps, how does allocating 2 MB Huge Pages (MAP_HUGETLB / madvise MADV_HUGEPAGE) improve C++ memory throughput?
MULTIPLE CHOICE • ADVANCED • +20 XP
Select all the benefits of using smart pointers in C++ applications.
MULTI SELECT • ADVANCED • +1 XP
A 16 GB in-memory C++ key-value store calls fork() to flush a point-in-time snapshot cleanly via OS Copy-on-Write (CoW) , while the parent thread keeps mutating hash-table nodes rapidly. Why can RSS spike toward 32 GB AND suddenly stall latency?
MULTIPLE CHOICE • ADVANCED • +20 XP
When uploading constant frames straight from C++ CPU buffers into host-visible PCIe Write-Combining (WC) GPU staging memory (Vulkan HOST_VISIBLE | HOST_COHERENT uncached RAM), why can accidentally reading back (dst[i] += ...) or writing randomly backwards inside WC memory crush upload bandwidth by 10–50x?
MULTIPLE CHOICE • ADVANCED • +20 XP
True or False: Even when storing a pointer temporarily inside uintptr_t (for XOR linked lists or low-bit tagging), restoring it back cleanly with reinterpret_cast<T*>(val & ~uintptr_t(0x7)) (stripping aligned lower tag bits) preserves valid access ONLY on pointers derived from the original object allocation (keeping provenance intact!), whereas synthesizing arbitrary guessed addresses from integers can violate compiler provenance (PNVI-ae-udi / Clang GVN).
TRUE FALSE • ADVANCED • +20 XP
To keep plaintext master keys inside an HSM/wallet process from ever spilling onto unencrypted disk swap partitions during OS memory pressure, C++ daemons pin those pages in physical RAM using POSIX _____(keyBuf, keyLen) (plus MADV_DONTDUMP via madvise).
FILL IN THE BLANK • ADVANCED • +20 XP
Two C++ matrices (4096 x 4096 floats vs 4099 x 4096 floats — note 4096 * 4 = 16384 = 2^14 bytes!) undergo vertical column stencils. Why does the 4096-wide matrix suffer dramatic slowdowns (up to 5–10x worse L1 misses!) compared to 4099-wide (padded)?
MULTIPLE CHOICE • ADVANCED • +20 XP
True or False: Passing a std::shared_ptr<Node> down into a worker sink via std::move(sp) avoids BOTH the atomic lock xadd increment on entry AND the atomic lock xadd decrement on exit (turning shared control-block churn cleanly into zero-atomic pointer move)!
TRUE FALSE • ADVANCED • +20 XP
Select all the best practices for memory management in C++ applications.
MULTI SELECT • ADVANCED • +1 XP
Why does even strongly ordered x86-64 hardware STILL fail Dekker’s / Peterson’s lock-free protocol if written with plain C++ memory_order_acquire/release (StoreLoad window) rather than memory_order_seq_cst (MFENCE / LOCK XCHG)?
MULTIPLE CHOICE • ADVANCED • +20 XP
Wait—we noted vec.push_back(vec[0]) IS valid cleanly in standard std::vector (handles self-aliasing). Now spot why myCustomPushBack below crashes when someone writes vec.push_back(vec[0]) inside a custom naive vector implementation!
CODE DEBUG • ADVANCED • +20 XP
When implementing a custom Vector<T>::reserve(newCap) over raw uninitialized storage (::operator new), select ALL hazards handled automatically if you use <memory> std::uninitialized_move_if_noexcept (+ ScopeGuard) instead of manual placement loops:
MULTI SELECT • ADVANCED • +20 XP
High-speed arena / pool allocators (O(1) instant teardown across 100,000 objects) can skip walking allocated nodes during reset safely ONLY when static_assert(std::_____<T>) verifies objects own zero external heap/OS handles requiring destructor cleanup.
FILL IN THE BLANK • ADVANCED • +20 XP
True or False: Under standard x86-64 Itanium C++ ABI (SysV), passing a non-trivial class std::unique_ptr<Foo> by value (even though sizeof == 8 bytes == raw pointer!) forces the compiler to pass it indirectly via stack hidden address rather than directly inside CPU register RDI (making non-owning Foo* strictly faster when not transferring ownership!).
TRUE FALSE • ADVANCED • +20 XP
Because std::aligned_storage had notorious strict-aliasing, subtle default-size (len) misuse, and UB defects (leading to deprecation in C++23!), modern custom containers (small_vector, inplace_any) reserve inline uninitialized storage simply via _____(T) std::byte storage[sizeof(T)];.
FILL IN THE BLANK • ADVANCED • +20 XP
Even without mutual A <-> B class links, select ALL sneaky ways std::shared_ptr STILL silently leaks entire object graphs forever:
MULTI SELECT • ADVANCED • +20 XP
Why does marking a C++ network wire struct __attribute__((packed)) / #pragma pack(1) and passing &pkt.field directly to helper functions void parse(const uint32_t& id) risk Undefined Behavior & ARM hardware faults ?
MULTIPLE CHOICE • ADVANCED • +20 XP
When traversing unpredictable hash buckets or sparse B-tree batches in C++ where hardware stream prefetchers cannot predict the next scattered RAM pointer, batch-issuing non-blocking __builtin_prefetch(nextPtr) ~8–16 iterations ahead overlaps DRAM ~100 ns latency cleanly behind active ALU work (Memory-Level _____).
FILL IN THE BLANK • ADVANCED • +20 XP
Select all that apply: What are common issues with manual memory management in C++ using pointers?
MULTI SELECT • ADVANCED • +1 XP
When storing a static 10,000,000-edge graph or spatial hierarchy in C++ memory, why does CSR (Compressed Sparse Row: two flat arrays rowOffsets[V+1] and neighbors[E]) destroy std::vector<std::vector<int>> adj(V) in throughput & memory?
MULTIPLE CHOICE • ADVANCED • +20 XP
When objects themselves store their next/prev link pointers or atomic reference counter directly inside their own class layout (zero extra control-block allocation, O(1) recover handle straight from raw T*), systems engines use _____ containers / smart pointers (like Boost.Intrusive / Unreal TRefCountPtr).
FILL IN THE BLANK • ADVANCED • +20 XP
Consider Base WITHOUT a virtual destructor (struct Base { ~Base() { ... } };). Why does creating std::shared_ptr<Base> p = std::make_shared<Derived>(); STILL cleanly invoke ~Derived() (prints D) at destruction—whereas std::unique_ptr<Base> would skip ~Derived() UB?!
CODE OUTPUT • ADVANCED • +20 XP