Tagged articles
memory allocation
66 articles · Page 1 of 1
This article presents a systematic approach to memory optimization across three dimensions—reducing allocation frequency, accelerating allocation speed, and improving memory usage efficiency—with practical C++ techniques including stack allocation, object pools, size-class allocators, huge pages, data structure packing, and false sharing prevention.
C++Memory OptimizationPerformance Tuning
0 likes · 23 min read

The article explains that stack memory allocation is quicker than heap allocation because the stack uses a simple pointer move and LIFO order, while the heap must search for free blocks, manage fragmentation, and often requires explicit deallocation, leading to higher overhead and potential leaks.
C++Interviewheap memory
0 likes · 65 min read

The article walks through the JVM’s internal steps that turn a simple `new User()` statement into a fully formed Java object, detailing memory allocation, the object header’s type pointer, the Klass structure, and why methods are stored at the class level rather than in each instance.
JVMJavaKlass
0 likes · 4 min read

The article reveals that using C++ new or malloc is far from cost‑free, detailing how Linux virtual address space, system‑call overhead, memory‑header metadata, fragmentation, and page‑fault latency all contribute to hidden performance penalties, and it offers concrete techniques such as stack allocation, memory pools, restrained PImpl usage, and startup pre‑allocation to mitigate these costs.
C++HeapLinux
0 likes · 23 min read

In a candid podcast conversation, Linux kernel maintainer Greg Kroah‑Hartman and Android Rust engineer Alice Ryhl explain how introducing Rust into the kernel not only forces clearer C interfaces and safer driver development but also rekindles the joy of programming for a veteran C developer.
C languageKlintLinux kernel
0 likes · 11 min read

Using Go 1.21’s experimental slices.Grow function to pre‑allocate slice capacity can dramatically reduce allocation overhead and latency, as demonstrated by a real‑world log‑aggregation service where response time dropped from 80 ms to 25 ms and memory allocations fell by 70 %.
BenchmarkGomemory allocation
0 likes · 8 min read

SLUB, the default Linux kernel memory allocator, reduces fragmentation and improves allocation speed for frequently created objects like task_struct and inode by using per‑CPU caches, object slabs, and NUMA‑aware node caches, with detailed structures, allocation/free paths, tuning parameters, and real‑world case studies.
Linux kernelNUMAPerformance Tuning
0 likes · 46 min read

Go provides two distinct constructors—new, a generic memory allocator returning a zero‑initialized pointer, and make, a specialized initializer that allocates and prepares slices, maps, and channels—explaining why both exist, how they differ, common pitfalls, and the language’s design philosophy of explicit, ready‑to‑use values.
GoReference Typeschannel
0 likes · 8 min read

This comprehensive guide explains the inner workings of the C malloc function, covering memory layout, stack vs heap, glibc memory pools, system calls like brk/sbrk and mmap, allocation strategies, fragmentation, alignment, multithreading safety, and comparisons with calloc, realloc, and C++ new.
c-programmingglibcheap management
0 likes · 53 min read

A detailed post‑mortem of a high‑priority fault on AMD servers shows how a split‑lock triggered by Python UDFs caused CPI spikes, CPU overload, and bus‑lock events, and explains the investigation steps, code analysis, reproduction tests, and mitigation measures taken to restore stability.
AMDjemallocmemory allocation
0 likes · 23 min read

This article dissects Netty 4.2's AdaptivePoolingAllocator memory allocation flow, covering request size routing, MagazineGroup's stripe mechanism with dynamic expansion, and Magazine's tryAllocate implementation with locked and lock-free paths using NEXT_IN_LINE for concurrency safety.
AdaptiveByteBufAllocatorChunkControllerMagazineGroup
0 likes · 13 min read

The article details the data structures behind Netty 4.2's AdaptiveByteBufAllocator, explaining how MagazineGroup, Magazine, and Chunk collaborate to manage memory pools, handle thread-local and shared allocation, and use size-classed chunks with free lists for efficient buffer pooling.
AdaptiveByteBufAllocatorByteBufChunk
0 likes · 6 min read

This article explains how the Linux kernel's kmalloc function provides fast, contiguous physical memory allocation using the slab allocator, covering its API, internal mechanisms, allocation flags, memory management strategies, common pitfalls, and practical kernel module examples for developers.
Linux kernelkernel-developmentkmalloc
0 likes · 73 min read

This article explains the fundamental differences between stack and heap memory allocation, covering their allocation mechanisms, performance characteristics, typical use cases such as stack overflow and memory leaks, and provides C and C++ code examples to illustrate each concept.
C++Memory Leakheap memory
0 likes · 60 min read

This article explains the fundamentals of malloc and free, covering their signatures, how they interact with the brk/sbrk system calls, the structure of memory control blocks, multiple allocation strategies such as explicit free lists, segregated lists, buddy systems and tcmalloc, along with code examples and their trade‑offs.
Dynamic Memoryc-programmingfree
0 likes · 15 min read

This article examines the internal design of glibc’s ptmalloc, explains how malloc_state, malloc_chunk, fastbins, bins and the top chunk work, analyzes lock contention and memory fragmentation in multithreaded scenarios, and presents a C benchmark that measures these performance issues.
C++freemalloc
0 likes · 12 min read

This article examines the inner workings of glibc’s ptmalloc, explains how malloc_state, malloc_chunk, fastbins and bins manage memory, and presents a multithreaded test that reveals lock contention and fragmentation problems that make the standard malloc/free unsuitable for high‑performance scenarios.
C++freemalloc
0 likes · 13 min read

This article explains why dynamic memory allocation is essential, models the heap as a parking lot, outlines the core challenges of implementing malloc and free, describes block headers, explores First Fit, Next Fit, and Best Fit strategies, and details splitting, internal fragmentation, and efficient coalescing using footers.
Systems Programmingallocation strategiesfragmentation
0 likes · 17 min read

Pointer collision is an efficient memory allocation technique that can trigger severe concurrency problems in multithreaded Java environments, and this article explains the underlying causes, illustrates conflict scenarios, and presents common remedies such as CAS (Compare‑And‑Swap) and TLAB (Thread‑Local Allocation Buffer) with sample code.
CASJavaMultithreading
0 likes · 6 min read

This article explains how the C functions malloc and free allocate and release memory, covering stack vs heap, the brk and mmap system calls, fragmentation, header metadata, and why both allocation strategies are needed for efficient memory management.
Heapbrkc-programming
0 likes · 17 min read

This article explains how the Linux kernel detects physical memory during boot by leveraging the E820 mechanism, where firmware reports memory ranges via interrupt 15H, enabling the kernel to map usable memory addresses for subsequent allocation.
E820Linux kernelboot process
0 likes · 8 min read

This article provides a comprehensive overview of Jemalloc, covering its architecture, memory allocation fundamentals, performance comparison with ptmalloc and tcmalloc, practical optimization cases across web, database, and big‑data workloads, and detailed configuration guidelines to improve memory efficiency and multithreaded performance.
Multithreadingfragmentationjemalloc
0 likes · 31 min read

This guide walks through creating a 32‑bit Linux‑kernel memory allocator using a free‑list, implementing morecore and add_to_free_list functions, and then adding a basic mark‑and‑sweep garbage collector that scans heap, BSS, data segments and the stack to reclaim unused blocks.
Linux kernelMark‑Sweepc-programming
0 likes · 12 min read

This article explains the purpose, prototype, and usage of C's malloc function, delves into its underlying implementation using free‑list mechanisms, virtual‑memory translation, system calls like brk and mmap, and compares it with related functions such as calloc, realloc and new, while providing practical code examples and best‑practice guidelines.
C++Dynamic Memoryfree
0 likes · 32 min read

This article explains the shared behavior of Go's new and make functions, highlights their key differences—including supported types, return values, and initialization details—and provides concrete code examples to show how each should be used in practice.
Gochannelmake
0 likes · 7 min read

The article dissects glibc's ptmalloc implementation, explaining malloc_state, malloc_chunk, fastbins, bins, and top chunk, then analyzes lock contention and fragmentation in multithreaded scenarios through a custom stress test, and concludes with recommendations for high‑performance memory management.
Concurrencyglibchigh-performance
0 likes · 12 min read

This article explains how Redis implements dynamic string expansion using the Simple Dynamic String (SDS) structure, detailing the sdsMakeRoomFor function, its allocation strategy, type handling, and the architectural changes introduced in Redis 7.0.
BackendC++Redis
0 likes · 10 min read

This article dissects the Linux kernel's page allocation mechanisms, explaining how alloc_pages() follows a fast‑path using low watermarks and falls back to a slow‑path that triggers kswapd, direct reclaim, and compaction, while also detailing the corresponding page‑freeing functions and their internal data structures.
Linux kernelbuddy allocatorcompaction
0 likes · 30 min read

This article analyzes why creating a resource pool with 4C12G fails in an OceanBase single‑node cluster despite sufficient CPU and memory, explains the relationship between LOG_DISK size and tenant memory, provides calculation formulas, verification steps, and practical recommendations to avoid LOG_DISK resource shortages.
LOG_DISKOceanBasedatabase administration
0 likes · 11 min read


ITPUBJul 30, 2024 · Databases
The article explains PostgreSQL's 1 GB memory allocation limit, shows how inserting large BYTEA values triggers the “invalid memory alloc request size” error, explores the underlying memory‑context code, and offers practical work‑arounds for migration from Oracle.
BYTEADatabase LimitsMaxAllocSize
0 likes · 8 min read

This article explains what happens inside a computer when you request memory with malloc, covering the role of the standard library, the compilation and linking process, memory layout, heap allocation, fragmentation, and how the operating system expands the heap.
Heapc-programmingmalloc
0 likes · 6 min read

This article explains what happens inside a computer when you request memory with malloc, covering the C standard library, compilation, memory layout, heap allocation, fragmentation, and how the operating system expands the heap using system calls.
Heapc-programmingfragmentation
0 likes · 6 min read

This article explains how memory allocation works in C, covering the role of malloc, the distinction between code and user data, the compilation and linking process, heap organization, fragmentation, and how the operating system expands the heap when needed.
Heapc-programmingfragmentation
0 likes · 6 min read

This comprehensive guide explains Linux memory fundamentals, address space layout, fragmentation, the buddy and slab allocators, kernel and user‑mode memory pools, DMA handling, common programming pitfalls, and practical tools for monitoring memory usage.
DMALinuxbuddy system
0 likes · 19 min read

The article explains a greedy interval‑based memory allocation problem, describes how to detect overlapping intervals, locate the smallest suitable free block within a 100‑byte heap, and provides a complete Python implementation that reads intervals, checks validity, and outputs the optimal allocation address.
algorithmic problemgreedy algorithminterval scheduling
0 likes · 6 min read

This article explains the principles and usage of dynamic memory allocation in C/C++ (malloc, calloc, realloc, free, new, delete), compares their behaviors, demonstrates common pitfalls, and extends the discussion to Linux kernel memory statistics, cache handling, swappiness tuning, and garbage‑collection concepts.
C++Linuxfree
0 likes · 31 min read

The article explains Go’s stack and heap memory, showing that stack allocations are fast, LIFO‑ordered and compile‑time sized while heap allocations grow upward, require garbage collection, and occur when variables escape a function, urging developers to prefer stack use for better performance.
GoHeapgarbage collection
0 likes · 6 min read

This article explains the internal representations of Go strings and byte slices, why converting between them incurs memory allocation and performance overhead, and provides safe and unsafe conversion techniques along with guidance on when to prefer each type.
StringType Conversionbyte slice
0 likes · 9 min read
![Why Converting Between Go string and []byte Costs More Than You Think](https://wsrv.nl/?url=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2FQFzRdz9libEYQ72PMKIbkQjpeTpo0eFEcNegTT7EOIUYBzQBwG4aM4SUO3GxX5ZU5M0ciaLnhosfGm3zibtianmhxQ%2F0%3Fwx_fmt%3Djpeg)
This article examines Linux memory management fundamentals, explains the brk/sbrk and mmap system calls, details the internal architectures, allocation and reclamation processes of ptmalloc and tcmalloc, analyzes key configuration parameters, and presents benchmark and production‑level results that demonstrate their impact on performance and memory usage.
BenchmarkLinuxTCMalloc
0 likes · 32 min read


政采云技术Sep 7, 2023 · Backend Development
This article explains how Netty implements memory management by borrowing concepts from Jemalloc and Tcmalloc, detailing the hierarchy of arenas, chunks, pages and sub‑pages, the allocation algorithms for both large and small buffers, and the role of thread‑local caches in reducing fragmentation and improving performance.
JavaNettybackend development
0 likes · 24 min read

This article explains the fundamentals of Linux memory allocation, introduces Jemalloc’s core algorithms and data structures, and provides concrete optimization steps—including arena tuning, tcache configuration, and slab size adjustments—to achieve measurable CPU savings in high‑concurrency C++ services.
ArenaC++jemalloc
0 likes · 19 min read

This article explains Linux's virtual address space layout, the six user‑space memory segments, how malloc decides between brk and mmap based on allocation size, the behavior of free, and why both allocation methods are needed for performance and memory management.
HeapLinuxSystem Programming
0 likes · 13 min read

An accidental discovery by a GitHub engineer revealed that moving a single '&' operator in a Go program eliminated unnecessary copies, reduced heap allocations via escape analysis, and improved execution speed by 42%, highlighting common pitfalls in Go’s regex engine, malloc, and garbage collection.
Gobackend developmentescape analysis
0 likes · 5 min read

This article examines the design goals, key implementation details, strengths and weaknesses of four widely used memory allocators—dlmalloc, jemalloc, Scudo, and PartitionAlloc—highlighting how they address fragmentation, performance, and security in virtual‑machine runtimes and offering guidance for building efficient, safe allocators.
Scudodlmallocjemalloc
0 likes · 27 min read

This article introduces hyengine, a lightweight, high‑performance engine designed to run multiple scripting languages such as JavaScript, WebAssembly, and Python on mobile devices, detailing its architecture, JIT compilation, optimizer passes, memory allocator, garbage collector, and performance benchmarks compared to LLVM and other runtimes.
CompilerJITgarbage collection
0 likes · 36 min read

This article explains the complete lifecycle of Java object creation, covering the JVM's handling of the new bytecode, class loading, memory allocation strategies such as pointer bumping and free lists, object header structure, layout, and tools for inspecting object memory.
JVMJavaObject Layout
0 likes · 13 min read

This guide shows how to use Linux's tmpfs file system together with simple commands like mount, dd, and taskset to allocate large amounts of RAM, simulate OOM conditions, and even target specific NUMA nodes without writing custom code.
MountOOM simulationdd
0 likes · 6 min read

This article presents a comprehensive collection of Baidu C++ engineers' performance‑optimization practices, covering memory‑access patterns, string handling, protobuf manipulation, allocator choices, job‑level memory arenas, cache‑line considerations, and memory‑order semantics to achieve substantial latency and cost reductions in large‑scale backend services.
Concurrencybackend developmentmemory allocation
0 likes · 32 min read

The article walks through Go’s memory allocator by first demonstrating assembly‑level debugging with Delve, then detailing its TCMalloc‑inspired design where tiny, small, and large objects follow distinct paths through per‑P caches, central spans, and the global heap, highlighting the roles of mcache, mcentral, mspan, and mheap.
DebuggingGCGo
0 likes · 28 min read

This article explains the Linux kernel's heap memory allocation process, covering the vm_area_struct and mm_struct data structures, the brk system call implementation, and the page‑fault handling that maps virtual addresses to physical memory, while also mentioning other allocation mechanisms such as mmap and HugePages.
HeapLinux kernelbrk system call
0 likes · 12 min read

This article shares Baidu C++ engineers' practical performance‑optimisation techniques, covering memory‑access patterns, custom allocation strategies, string handling, protobuf handling, cache‑line considerations and memory‑order semantics to achieve significant latency and cost reductions in large‑scale backend services.
backend developmentmemory allocationperformance optimization
0 likes · 32 min read


21CTOApr 24, 2021 · Backend Development
This article explores Baidu C++ engineers' deep‑dive into performance optimization, covering memory‑access patterns, string‑buffer handling, protobuf merging, malloc strategies, job‑arena allocation, cache‑line effects, and modern memory‑order semantics to achieve multi‑fold speedups in large‑scale backend services.
C++ConcurrencyProtobuf
0 likes · 33 min read

Baidu engineers boost C++ backend latency and cost efficiency by eliminating unnecessary string zero‑initialization, using zero‑copy split with SIMD, replacing deep protobuf merges with repeated string fields, employing job‑scoped arenas and custom memory resources for allocation, and applying prefetching, cache‑line awareness, and tuned memory‑order semantics, achieving multiplicative to order‑of‑magnitude speedups.
Memory Accesscache linejob arena
0 likes · 31 min read

This article explains the nature of Go's nil keyword, how it interacts with different types such as slices, maps, channels, interfaces, pointers and functions, and clarifies variable definition, zero‑value allocation, make versus var, and the compiler's nil handling semantics.
BackendType Systemmemory allocation
0 likes · 15 min read

By adding model warm‑up files, separating load/unload threads, switching to the Jemalloc allocator, and isolating TensorFlow’s parameter memory from RPC request buffers, iQIYI’s engineers reduced TensorFlow Serving hot‑update latency spikes in high‑throughput CTR recommendation services from over 120 ms to about 2 ms, eliminating jitter.
Model Hot UpdateTensorFlow Servingjemalloc
0 likes · 11 min read

Go's escape analysis determines whether variables are allocated on the stack or heap, influencing garbage collection overhead; this guide explains the analysis principles, shows how to enable compiler logs, and demonstrates through multiple code examples how different patterns cause or avoid variable escape.
Compiler FlagsGoescape analysis
0 likes · 8 min read

This article explains how Objective‑C creates objects by detailing the two creation methods, the internal alloc and init implementations, the callAlloc workflow, memory allocation, and the final binding of the isa pointer, with full source code excerpts for each step.
Object CreationObjective-C++Runtime
0 likes · 11 min read

This article explains the JVM's process for creating a Java object, covering class loading checks, memory allocation strategies such as bump-pointer and free list, thread-safe allocation mechanisms, object header composition, instance data layout, padding, and the ways references locate objects via handles or direct pointers.
JVMObject CreationObject Layout
0 likes · 7 min read

This article explains how Netty achieves high‑performance, scalable networking by addressing the C10K and C10M problems through efficient I/O models, multithreading, zero‑copy ByteBuf handling, memory allocation strategies, and resource management techniques, providing practical code examples and architectural diagrams.
ByteBufC10KC10M
0 likes · 25 min read

This article explains how the JVM allocates memory for Java objects, discusses the thread‑safety challenges of concurrent allocations, and describes the Thread‑Local Allocation Buffer (TLAB) mechanism and its impact on performance and garbage collection.
BackendJVMJava
0 likes · 6 min read

The article analyzes a MySQL 5.6 high‑CPU issue triggered by a frequently executed query with many UID values, identifies mutex contention and excessive memory allocation in InnoDB as root causes, and presents a solution of switching the memory allocator to tcmalloc with configuration changes.
CPUInnoDBMutex
0 likes · 4 min read

This article explains how Python lists manage memory during initialization and appends, examines CPython's internal allocation algorithm, demonstrates memory growth with practical code examples, and recommends using list comprehensions for more efficient list creation.
ListPythonappend
0 likes · 10 min read


ITPUBJun 8, 2017 · Operations
After a recent Bash upgrade on certain servers, SSH logins intermittently failed due to bash’s inability to allocate memory, prompting an investigation that revealed differences in 32‑bit and 64‑bit process memory layouts, exec‑shield behavior, and kernel mmap handling on CentOS 6.5.
32-bit64-bitProcess Layout
0 likes · 12 min read

This article shares years of server‑development experience, explaining how data copies, context switches, memory allocation, and lock contention act as the four main performance killers and offering practical strategies to mitigate each for faster, more scalable services.
context switchesdata copieslock contention
0 likes · 21 min read


ITPUBNov 7, 2016 · Databases
This article provides an in‑depth technical walkthrough of MySQL’s MEM_ROOT memory allocator, covering the key macros, the MEM_ROOT and USED_MEM structures, initialization and allocation routines, pointer‑manipulation logic, and the heuristic algorithm that grows block sizes as usage increases.
C++Database InternalsMEM_ROOT
0 likes · 8 min read


ITPUBApr 12, 2016 · Backend Development
This article explains MySQL's widely used MEM_ROOT memory allocator, detailing its macros, the MEM_ROOT and USED_MEM structures, initialization routine, allocation algorithm, and pointer handling, while illustrating how free and used blocks are managed via linked lists.
C++MEM_ROOTMySQL
0 likes · 8 min read
