Tag: memory
15 posts
-
Linux Internals & Operations: CFS Scheduling and Page Cache
CFS scheduler, page cache and swap, VFS and dentry/inode, syscall path and observability, cgroups v2 and production SRE patterns.
-
How Go Slices Really Work: Header Layout, append Growth, Shared Backing Arrays and Pitfalls
Go slice internal structure, memory allocation mechanism, capacity vs length, append operation principles, performance optimization techniques.
-
C++ Alignment and Padding: Why sizeof Surprises You, alignas, #pragma pack and False Sharing
Where struct padding comes from, how member order changes sizeof, what alignas and #pragma pack really do, why packed structs are risky, and false sharing.
-
static Functions in C++: Class Statics vs File-Scope Statics, Linkage and the ODR
How static functions behave in C++ - class static member functions, file-scope static functions and internal linkage, ODR implications, and their effect on memory layout and performance.
-
C++ Stack Overflow: Recursion, Large Locals, and How to Fix
Why C++ programs overflow the stack, from runaway recursion to large local arrays, and how to fix it with ulimit or /STACK, heap allocation or iteration.
-
C++ Use-After-Free (UAF): Causes, ASan, and Ownership Rules
Why use-after-free bugs in C++ hide until much later, the patterns that cause them (invalidation, escaped raw pointers, callbacks), and how ASan pinpoints them.
-
Valgrind for C++: Reading Memcheck Output, Leak Kinds, and When to Use ASan Instead
Run Valgrind Memcheck on C++ code, read its reports line by line, tell definitely lost from still reachable, write suppressions, and know when ASan fits better.
-
C++ Sanitizers: ASan, TSan, UBSan, and MSan Explained
How C++ sanitizers work and what each one misses: ASan shadow memory, TSan happens-before tracking, UBSan recovery mode, MSan instrumentation rules, and CI setups that actually fail the build.
-
C++ Object Lifetime: Storage Duration, RAII, and Dangling
C++ lifetime and storage duration: automatic, static, dynamic, thread_local; destruction order; temporaries; smart pointers and RAII.
-
C++ Heap Corruption: Double Free and Wrong delete
Why heap corruption crashes far from the bug that caused it: overruns, double delete, delete vs delete[], and use-after-free, plus how ASan, Valgrind, and page heap catch them at the source.
-
C++ vector reserve vs resize: When to Use Which
vector::reserve changes capacity only while resize changes size and constructs elements. Covers the v[i]-after-reserve bug, growth rules, and reserve-in-a-loop.
-
C++ Buffer Overflows: Causes, Safe APIs, and Security Impact
Buffer overflows in C and C++: strcpy, memcpy, stack and heap corruption, ASan, strncpy vs string, bounds checks, and secure coding patterns.
-
C++ Cache Optimization: Locality, False Sharing, SoA vs AoS
Improve CPU cache efficiency in C++: spatial locality, matrix layout, struct packing, prefetching, blocking, false sharing, and alignment for SIMD.
-
C++ Custom Allocators for STL Containers: Pool, Stack, Tracking Allocators and PMR
Default std::allocator, passing allocators to containers, custom pool and tracking allocators, PMR monotonic_buffer_resource.
-
The Flyweight Pattern in C++: Sharing Intrinsic State to Cut Memory in Text and Tile Maps
Flyweight in C++: split shared intrinsic state from per-object extrinsic state, with glyph, font and tile-map examples and the mutation and cache-growth traps.