# jessa2005/heap-memory-management-implementation architecture

> Architecture diagram of the GitHub repository jessa2005/heap-memory-management-implementation, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jessa2005/heap-memory-management-implementation
- Repository: https://github.com/jessa2005/heap-memory-management-implementation

## Overview

HMM is a Linux user-space allocator that replaces the standard allocation API, managing aligned blocks in the process heap via sbrk. The main workflow is a caller requesting memory through the public API or libc-compatible wrappers; allocation searches and splits free blocks, while freeing coalesces neighbors and may return heap space to the OS. Extended operations provide calloc, realloc, and size queries. The graph reflects the sampled allocator sources and README capabilities; static linking and LD_PRELOAD are documented, but their build/configuration details are outside this runtime view.

Main entry points: [`src/HmmAlloc.c`](https://github.com/jessa2005/heap-memory-management-implementation/blob/main/src/HmmAlloc.c) (Allocation), [`src/HmmFree.c`](https://github.com/jessa2005/heap-memory-management-implementation/blob/main/src/HmmFree.c) (Free and Coalesce), [`inc/Hmm.h`](https://github.com/jessa2005/heap-memory-management-implementation/blob/main/inc/Hmm.h) (Public API), [`src/heapWrappers.c`](https://github.com/jessa2005/heap-memory-management-implementation/blob/main/src/heapWrappers.c) (Libc Wrappers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Allocation API"]
  node_public_api["Public API<br/>[Hmm.h]"]
  node_wrappers["Libc Wrappers<br/>[heapWrappers.c]"]
  node_extended["Extended Operations<br/>[HmmEx.c]"]
end

subgraph group_allocator["Heap Management"]
  node_allocator_core["Allocation<br/>[HmmAlloc.c]"]
  node_alignment["Heap Alignment<br/>[HmmAlloc.c]"]
  node_fit_split["Fit and Split<br/>[HmmAlloc.c]"]
  node_heap_growth["Heap Expansion<br/>[HmmAlloc.c]"]
  node_free_coalesce["Free and Coalesce<br/>[HmmFree.c]"]
  node_heap_shrink["Heap Contraction<br/>[HmmFree.c]"]
  node_block_state["Block Metadata<br/>[hmm_int.h]"]
  node_free_list["Free List<br/>[hmm_int.h]"]
  node_physical_links["Physical Links<br/>[hmm_int.h]"]
end

subgraph group_platform["Heap Platform"]
  node_program_break[("Process Break")]
end

node_caller(("Application"))

node_caller -.->|"calls"| node_wrappers
node_caller -->|"calls"| node_public_api
node_wrappers -->|"allocates"| node_allocator_core
node_wrappers -->|"frees"| node_free_coalesce
node_wrappers -->|"delegates"| node_extended
node_public_api -->|"exposes"| node_allocator_core
node_public_api -->|"exposes"| node_free_coalesce
node_public_api -->|"exposes"| node_extended
node_allocator_core -->|"aligns"| node_alignment
node_allocator_core -->|"searches"| node_fit_split
node_allocator_core -->|"expands"| node_heap_growth
node_allocator_core -->|"updates"| node_free_list
node_allocator_core -->|"updates"| node_block_state
node_fit_split -->|"updates"| node_physical_links
node_free_coalesce -->|"updates"| node_free_list
node_free_coalesce -->|"coalesces"| node_physical_links
node_free_coalesce -->|"contracts"| node_heap_shrink
node_extended -->|"allocates"| node_allocator_core
node_extended -->|"frees"| node_free_coalesce
node_heap_growth -->|"grows"| node_program_break
node_alignment -->|"aligns"| node_program_break
node_heap_shrink -->|"releases"| node_program_break

click node_public_api "https://github.com/jessa2005/heap-memory-management-implementation/blob/main/inc/Hmm.h"
click node_wrappers "https://github.com/jessa2005/heap-memory-management-implementation/blob/main/src/heapWrappers.c"
click node_extended "https://github.com/jessa2005/heap-memory-management-implementation/blob/main/src/HmmEx.c"
click node_allocator_core "https://github.com/jessa2005/heap-memory-management-implementation/blob/main/src/HmmAlloc.c"
click node_alignment "https://github.com/jessa2005/heap-memory-management-implementation/blob/main/src/HmmAlloc.c"
click node_fit_split "https://github.com/jessa2005/heap-memory-management-implementation/blob/main/src/HmmAlloc.c"
click node_heap_growth "https://github.com/jessa2005/heap-memory-management-implementation/blob/main/src/HmmAlloc.c"
click node_free_coalesce "https://github.com/jessa2005/heap-memory-management-implementation/blob/main/src/HmmFree.c"
click node_heap_shrink "https://github.com/jessa2005/heap-memory-management-implementation/blob/main/src/HmmFree.c"
click node_block_state "https://github.com/jessa2005/heap-memory-management-implementation/blob/main/inc/hmm_int.h"
click node_free_list "https://github.com/jessa2005/heap-memory-management-implementation/blob/main/inc/hmm_int.h"
click node_physical_links "https://github.com/jessa2005/heap-memory-management-implementation/blob/main/inc/hmm_int.h"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_public_api,node_wrappers,node_extended toneBlue
class node_allocator_core,node_alignment,node_fit_split,node_heap_growth,node_free_coalesce,node_heap_shrink,node_block_state,node_free_list,node_physical_links toneAmber
class node_program_break toneMint
class node_caller toneIndigo
```

## Components

### Allocation API

- [Public API](https://github.com/jessa2005/heap-memory-management-implementation/blob/main/inc/Hmm.h): `inc/Hmm.h`
- [Libc Wrappers](https://github.com/jessa2005/heap-memory-management-implementation/blob/main/src/heapWrappers.c): `src/heapWrappers.c`
- [Extended Operations](https://github.com/jessa2005/heap-memory-management-implementation/blob/main/src/HmmEx.c): `src/HmmEx.c`

### Heap Management

- [Allocation](https://github.com/jessa2005/heap-memory-management-implementation/blob/main/src/HmmAlloc.c): `src/HmmAlloc.c`
- [Heap Alignment](https://github.com/jessa2005/heap-memory-management-implementation/blob/main/src/HmmAlloc.c): `src/HmmAlloc.c`
- [Fit and Split](https://github.com/jessa2005/heap-memory-management-implementation/blob/main/src/HmmAlloc.c): `src/HmmAlloc.c`
- [Heap Expansion](https://github.com/jessa2005/heap-memory-management-implementation/blob/main/src/HmmAlloc.c): `src/HmmAlloc.c`
- [Free and Coalesce](https://github.com/jessa2005/heap-memory-management-implementation/blob/main/src/HmmFree.c): `src/HmmFree.c`
- [Heap Contraction](https://github.com/jessa2005/heap-memory-management-implementation/blob/main/src/HmmFree.c): `src/HmmFree.c`
- [Block Metadata](https://github.com/jessa2005/heap-memory-management-implementation/blob/main/inc/hmm_int.h): `inc/hmm_int.h`
- [Free List](https://github.com/jessa2005/heap-memory-management-implementation/blob/main/inc/hmm_int.h): `inc/hmm_int.h`
- [Physical Links](https://github.com/jessa2005/heap-memory-management-implementation/blob/main/inc/hmm_int.h): `inc/hmm_int.h`

### Heap Platform

- **Process Break**

### Other components

- **Application**

## Connections

- Application → Libc Wrappers: calls (evidence: `README.md`)
- Application → Public API: calls (evidence: `README.md`)
- Libc Wrappers → Allocation: allocates (evidence: `src/heapWrappers.c`)
- Libc Wrappers → Free and Coalesce: frees (evidence: `src/heapWrappers.c`)
- Libc Wrappers → Extended Operations: delegates (evidence: `src/heapWrappers.c`)
- Public API → Allocation: exposes (evidence: `README.md`)
- Public API → Free and Coalesce: exposes (evidence: `README.md`)
- Public API → Extended Operations: exposes (evidence: `inc/Hmm.h`)
- Allocation → Heap Alignment: aligns (evidence: `src/HmmAlloc.c`)
- Allocation → Fit and Split: searches (evidence: `src/HmmAlloc.c`)
- Allocation → Heap Expansion: expands (evidence: `src/HmmAlloc.c`)
- Allocation → Free List: updates (evidence: `src/HmmAlloc.c`)
- Allocation → Block Metadata: updates (evidence: `src/HmmAlloc.c`)
- Fit and Split → Physical Links: updates (evidence: `src/HmmAlloc.c`)
- Free and Coalesce → Free List: updates (evidence: `src/HmmFree.c`)
- Free and Coalesce → Physical Links: coalesces (evidence: `src/HmmFree.c`)
- Free and Coalesce → Heap Contraction: contracts (evidence: `src/HmmFree.c`)
- Extended Operations → Allocation: allocates (evidence: `src/HmmEx.c`)
- Extended Operations → Free and Coalesce: frees (evidence: `src/HmmEx.c`)
- Heap Expansion → Process Break: grows (evidence: `src/HmmAlloc.c`)
- Heap Alignment → Process Break: aligns (evidence: `src/HmmAlloc.c`)
- Heap Contraction → Process Break: releases (evidence: `src/HmmFree.c`)
