Tagged articles
51 articles
Page 1 of 1
Deepin Linux
Deepin Linux
Mar 5, 2026 · Fundamentals

Unveiling malloc: How C Allocates Memory Behind the Scenes

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
Unveiling malloc: How C Allocates Memory Behind the Scenes
Linux Kernel Journey
Linux Kernel Journey
Nov 17, 2025 · Operations

Four Diagrams to Quickly Diagnose Linux Memory Leaks

This guide explains Linux's virtual‑physical memory model, shows how to inspect system and process memory via /proc files, demonstrates a 100 MiB allocation test, and provides a step‑by‑step workflow—including ps sorting and Valgrind usage—to locate and fix memory leaks.

DebuggingLinuxmalloc
0 likes · 16 min read
Four Diagrams to Quickly Diagnose Linux Memory Leaks
Huawei Cloud Developer Alliance
Huawei Cloud Developer Alliance
Oct 20, 2025 · Fundamentals

Why Does a C++ Program Crash on free() Even When It Looks Correct?

Even when a C++ program appears to run correctly, writing beyond allocated memory can corrupt heap metadata, causing a delayed crash at free(); this article explains the underlying malloc/free mechanisms, demonstrates the issue with code examples, and offers debugging tools and defensive programming practices to prevent such errors.

CDebuggingFree
0 likes · 9 min read
Why Does a C++ Program Crash on free() Even When It Looks Correct?
Deepin Linux
Deepin Linux
Sep 23, 2025 · Fundamentals

Mastering Linux Memory Allocation: When to Use brk vs mmap

This article explains the low‑level mechanisms of brk and mmap in Linux, compares their characteristics, shows why malloc selects one over the other based on allocation size, and provides practical code examples, performance tips, and common pitfalls for developers.

LinuxMemory ManagementPerformance Optimization
0 likes · 29 min read
Mastering Linux Memory Allocation: When to Use brk vs mmap
Deepin Linux
Deepin Linux
Sep 19, 2025 · Fundamentals

Unlocking Linux Memory: How Virtual Memory, MMU, and Heap Really Work

This article demystifies Linux process memory by explaining the layered architecture of virtual and physical memory, the role of the MMU and page tables, dynamic allocation mechanisms such as brk and mmap, and practical tools for inspecting and optimizing memory usage.

LinuxMMUMemory Management
0 likes · 47 min read
Unlocking Linux Memory: How Virtual Memory, MMU, and Heap Really Work
Deepin Linux
Deepin Linux
Sep 17, 2025 · Fundamentals

Why new/delete Beats malloc/free: A Deep Dive into C/C++ Memory Management

This article explains the core differences between C's malloc/free and C++'s new/delete, covering allocation mechanisms, object construction and destruction, error handling, common pitfalls, and best practices—including smart pointers—to help developers choose the right memory management approach for various programming scenarios.

Callocationmalloc
0 likes · 32 min read
Why new/delete Beats malloc/free: A Deep Dive into C/C++ Memory Management
Deepin Linux
Deepin Linux
Sep 11, 2025 · Fundamentals

Mastering C++ Memory: When to Use new/delete vs malloc/free

This article explains the fundamental differences between C's malloc/free and C++'s new/delete, covering their underlying mechanisms, proper usage patterns, common pitfalls, error‑handling strategies, and best‑practice recommendations such as smart pointers and memory‑pool techniques.

CMemory Managementmalloc
0 likes · 29 min read
Mastering C++ Memory: When to Use new/delete vs malloc/free
Deepin Linux
Deepin Linux
Aug 23, 2025 · Fundamentals

How Does delete Know Memory Size? A Deep Dive into C++ Memory Management

This article explains C++ memory management fundamentals, detailing how delete and free release memory without explicit size knowledge, the role of stack, heap, data and code segments, differences between new/delete and malloc/free, array handling, common pitfalls, and interview questions with code examples.

CDELETEFree
0 likes · 34 min read
How Does delete Know Memory Size? A Deep Dive into C++ Memory Management
Liangxu Linux
Liangxu Linux
Aug 19, 2025 · Fundamentals

How malloc and free Work: Inside Dynamic Memory Allocation

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.

C programmingFreedynamic memory
0 likes · 15 min read
How malloc and free Work: Inside Dynamic Memory Allocation
IT Services Circle
IT Services Circle
Jun 8, 2025 · Information Security

Why mmap Shared Memory Is More Dangerous Than malloc – Risks Explained

mmap shared memory lets multiple processes access the same physical memory, which can break process isolation, expose permission misconfigurations like PROT_EXEC, and cause cross‑process crashes or code‑injection attacks, making it far riskier than heap allocations with malloc that remain confined to a single process.

C programmingSecuritymalloc
0 likes · 5 min read
Why mmap Shared Memory Is More Dangerous Than malloc – Risks Explained
Deepin Linux
Deepin Linux
Jun 6, 2025 · Fundamentals

Unlocking Linux Memory Management: From malloc to Buddy Allocation

This comprehensive guide explores Linux's memory management ecosystem, detailing user‑space allocators like malloc, kernel‑space mechanisms such as kmalloc, vmalloc, and mmap, and core kernel algorithms including the Buddy system, CMA, slab allocator, and memory pools, while providing code examples and practical usage tips.

Buddy AlgorithmLinuxMemory Management
0 likes · 60 min read
Unlocking Linux Memory Management: From malloc to Buddy Allocation
Deepin Linux
Deepin Linux
May 28, 2025 · Fundamentals

Understanding Heap Memory Management in C: Detailed Guide to malloc and free

This article provides a comprehensive overview of heap memory management in C, explaining the concepts of heap versus stack, the usage and internal mechanisms of malloc and free, common pitfalls such as memory leaks and dangling pointers, and compares these functions with new/delete, calloc, and realloc.

CFreeHeap
0 likes · 29 min read
Understanding Heap Memory Management in C: Detailed Guide to malloc and free
Deepin Linux
Deepin Linux
May 28, 2025 · Fundamentals

Understanding glibc malloc: Overview, Mechanisms, and Optimization Techniques

This article explains the role of glibc malloc in dynamic memory allocation, describes its internal data structures and allocation/free algorithms, provides a C code example, and offers practical optimization tips and common pitfalls for safe and efficient memory management.

C programmingMemory Managementdynamic allocation
0 likes · 13 min read
Understanding glibc malloc: Overview, Mechanisms, and Optimization Techniques
Deepin Linux
Deepin Linux
May 1, 2025 · Fundamentals

Understanding Memory and Process Interaction: Virtual Memory, Paging, and Allocation in Linux

This article explains how memory works as a temporary storage stage for processes, describes the fundamentals of physical and virtual memory, details paging, page tables, multi‑level paging, allocation mechanisms such as brk() and mmap(), and outlines Linux memory‑management techniques including caching, swapping, and OOM handling.

MMUMemory ManagementOOM
0 likes · 33 min read
Understanding Memory and Process Interaction: Virtual Memory, Paging, and Allocation in Linux
Liangxu Linux
Liangxu Linux
Apr 2, 2025 · Fundamentals

How Does malloc Actually Work? Inside a Simple Memory Allocator

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
How Does malloc Actually Work? Inside a Simple Memory Allocator
Deepin Linux
Deepin Linux
Feb 27, 2025 · Fundamentals

Understanding malloc and free: Memory Allocation Mechanisms in C

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.

C programmingFreeHeap
0 likes · 17 min read
Understanding malloc and free: Memory Allocation Mechanisms in C
Liangxu Linux
Liangxu Linux
Jan 16, 2025 · Fundamentals

Building a Simple malloc and Mark‑Sweep GC for the Linux Kernel

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.

C programmingGarbage CollectionLinux kernel
0 likes · 12 min read
Building a Simple malloc and Mark‑Sweep GC for the Linux Kernel
Linux Kernel Journey
Linux Kernel Journey
Jan 9, 2025 · Fundamentals

How Does a Linux Process Use Memory? A Deep Dive

This article explains the Linux kernel’s memory management for a process, covering virtual address spaces, page‑fault handling, VMA allocation, stack and heap initialization, sbrk/brk usage, thread‑stack creation, and the glibc ptmalloc heap allocator with concrete code examples and diagrams.

HeapLinuxPage Fault
0 likes · 15 min read
How Does a Linux Process Use Memory? A Deep Dive
Deepin Linux
Deepin Linux
Dec 19, 2024 · Fundamentals

Understanding the Implementation and Mechanisms of the C malloc Function

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.

CFreedynamic memory
0 likes · 32 min read
Understanding the Implementation and Mechanisms of the C malloc Function
Linux Kernel Journey
Linux Kernel Journey
Dec 8, 2024 · Fundamentals

Linux Kernel Source Analysis: Understanding Heap Memory Management

This article explains how the Linux kernel implements heap memory management, covering the heap data structure, the mm_struct fields start_brk and brk, the brk/sbrk and malloc/free allocation methods, the brk and mmap system calls, and the internal glibc structures heap_info and malloc_state that track heap state.

Heap MemoryKernelLinux
0 likes · 17 min read
Linux Kernel Source Analysis: Understanding Heap Memory Management
Liangxu Linux
Liangxu Linux
Aug 12, 2024 · Fundamentals

Understanding C Memory Leaks: Causes, Detection, and Prevention

This article explains why memory leaks occur only with heap allocations in C, describes how malloc and related functions allocate memory, outlines two common ways to obtain heap memory, identifies the three essential elements of a leak, debunks common freeing misconceptions, and provides practical inspection steps to prevent leaks.

CDebuggingHeap
0 likes · 6 min read
Understanding C Memory Leaks: Causes, Detection, and Prevention
Liangxu Linux
Liangxu Linux
Jul 27, 2024 · Fundamentals

Does malloc Allocate Memory? Exploring Virtual Memory, brk, and Page Faults

This article explains why calling malloc in C only reserves virtual address space, how the kernel maps it to physical memory on demand, and the roles of the brk pointer, memory layout, and page‑fault handling, illustrated with a 1 GB allocation example and detailed diagrams.

C programmingMemory ManagementPage Fault
0 likes · 7 min read
Does malloc Allocate Memory? Exploring Virtual Memory, brk, and Page Faults
Liangxu Linux
Liangxu Linux
Jul 13, 2024 · Fundamentals

How Does malloc Actually Allocate Memory? A Visual Walkthrough

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.

C programmingHeapOperating System
0 likes · 6 min read
How Does malloc Actually Allocate Memory? A Visual Walkthrough
Java Tech Enthusiast
Java Tech Enthusiast
Jun 29, 2024 · Fundamentals

Understanding Memory Allocation in C

The article explains C’s memory allocation, detailing how functions like malloc obtain heap space, the role of system calls such as brk, the distinction between stack and heap, address layout, fragmentation challenges, and practical implications for efficient dynamic memory management.

C programmingHeapMemory Fragmentation
0 likes · 5 min read
Understanding Memory Allocation in C
Deepin Linux
Deepin Linux
Nov 20, 2023 · Fundamentals

Linux Memory Allocation Mechanisms: malloc, kmalloc, vmalloc, mmap, and Slab

This article explains Linux's flexible memory allocation system, covering user‑space malloc, kernel‑space kmalloc, vmalloc for large buffers, mmap for file and anonymous mappings, page allocation functions, the slab allocator, and memory pools, with detailed code examples and operational insights.

Linuxkmallocmalloc
0 likes · 30 min read
Linux Memory Allocation Mechanisms: malloc, kmalloc, vmalloc, mmap, and Slab
Zhuanzhuan Tech
Zhuanzhuan Tech
Sep 14, 2023 · Fundamentals

Analysis and Comparison of ptmalloc and tcmalloc Memory Allocators on Linux

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
Analysis and Comparison of ptmalloc and tcmalloc Memory Allocators on Linux
ByteDance SYS Tech
ByteDance SYS Tech
May 19, 2023 · Backend Development

Why DPDK Memory Allocation Slows Down and How to Fix It

This article investigates the performance degradation caused by DPDK memory fragmentation, explains the underlying heap and element management, presents detailed profiling and test results, and proposes two practical solutions that dramatically reduce allocation latency and improve overall system throughput.

CDPDKMemory Fragmentation
0 likes · 16 min read
Why DPDK Memory Allocation Slows Down and How to Fix It
AI Cyberspace
AI Cyberspace
Mar 25, 2023 · Fundamentals

Mastering C Memory Management: malloc, realloc, memset, memcpy & More

This article explains how C programs allocate, resize, initialize, and transfer memory using functions like malloc, free, realloc, memset, memcpy, memmove, and alloca, and provides coding standards to avoid out‑of‑bounds errors, leaks, and use‑after‑free bugs.

CMemcpyStack
0 likes · 11 min read
Mastering C Memory Management: malloc, realloc, memset, memcpy & More
Baidu Geek Talk
Baidu Geek Talk
Dec 16, 2022 · Fundamentals

Exploring ptmalloc: Memory Management in Linux C++ Programs

The article explains how glibc’s default ptmalloc allocator structures memory into main and non‑main arenas, uses chunk‑based bins (fast, unsorted, small, large) for allocation and deallocation, details its locking and OS‑interaction mechanisms, and evaluates its design trade‑offs versus modern allocators.

CFreeLinux
0 likes · 12 min read
Exploring ptmalloc: Memory Management in Linux C++ Programs
ByteDance Web Infra
ByteDance Web Infra
Aug 19, 2022 · Fundamentals

In‑Depth Analysis of dlmalloc, jemalloc, Scudo, and PartitionAlloc for Virtual‑Machine Memory Management

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
In‑Depth Analysis of dlmalloc, jemalloc, Scudo, and PartitionAlloc for Virtual‑Machine Memory Management
Baidu App Technology
Baidu App Technology
Jul 12, 2022 · Mobile Development

Large Memory Allocation Monitoring Solution for iOS Applications

A low‑overhead monitoring solution for iOS apps resets the global malloc_logger to capture every allocation, filters large allocations exceeding a configurable threshold, records lightweight stack traces using dyld image maps, and sends address‑only data for offline symbolication, enabling developers to identify and fix memory‑heavy code, reducing OOM crashes.

Memory MonitoringMobile DevelopmentOOM
0 likes · 14 min read
Large Memory Allocation Monitoring Solution for iOS Applications
ITPUB
ITPUB
Jan 27, 2022 · Fundamentals

Why Does Linux Need Complex Memory Management? Inside Virtual Memory, malloc, and OOM

This article explains the reasons behind Linux's sophisticated memory management, covering virtual memory mechanisms, page tables, MMU/TLB interactions, page fault handling, the layout of a process's address space, glibc's malloc internals, memory reclamation techniques, and the OOM killer's decision process.

KernelLinuxOOM
0 likes · 33 min read
Why Does Linux Need Complex Memory Management? Inside Virtual Memory, malloc, and OOM
Liangxu Linux
Liangxu Linux
Feb 6, 2021 · Backend Development

Why Standard malloc Slows You Down and How Custom Memory Pools Supercharge Performance

Although malloc is a universal allocator, its lack of scenario-specific optimization makes it unsuitable for high‑performance server applications; this article explains malloc’s internal workflow, compares it with custom memory‑pool techniques, and details various pool designs, thread‑safety strategies, and an interesting cross‑thread free problem.

Backend DevelopmentC++Memory Management
0 likes · 14 min read
Why Standard malloc Slows You Down and How Custom Memory Pools Supercharge Performance
ITPUB
ITPUB
Sep 15, 2017 · Fundamentals

How Linux and glibc Manage Memory: From Virtual Allocation to Physical Release

This article explains Linux's two‑level memory model, lazy physical allocation, the glibc malloc implementation, chunk metadata, large‑vs‑small allocations, memory holes, debugging hooks, leak detection with mtrace, and practical ways to measure a process's memory usage via /proc.

DebuggingMemory Managementglibc
0 likes · 15 min read
How Linux and glibc Manage Memory: From Virtual Allocation to Physical Release
Baidu Intelligent Testing
Baidu Intelligent Testing
Jun 14, 2016 · Fundamentals

Analysis of Common C/C++ Memory Issues: Leaks and Performance Degradation

This article examines typical C/C++ memory problems, classifying them into memory leaks and performance issues caused by fragmentation, explains root causes such as lost pointers, improper releases, unbounded allocations, and provides diagnostic examples and mitigation strategies using memory pools like tcmalloc.

CDebuggingMemory Fragmentation
0 likes · 13 min read
Analysis of Common C/C++ Memory Issues: Leaks and Performance Degradation