Skip to content

Instantly share code, notes, and snippets.

# Architecture Comparison: Stack vs Heap vs Hybrid
**Goal:** Choose the optimal memory architecture for miniRT world storage based on performance, memory usage, and code complexity.
## Quick Comparison Table
| Criteria | Pure Stack | Pure Heap | **Hybrid** |
|----------|------------|-----------|------------|
| **Memory (10 objects)** | 11.2 KB | ~1 KB | **1.8 KB** ✅ |
| **Memory (100 objects)** | ❌ FAIL | ~14 KB | **~14 KB** ✅ |
# Architecture Comparison: Stack vs Heap vs Hybrid
**Goal:** Choose the optimal memory architecture for miniRT world storage based on performance, memory usage, and code complexity.
## Quick Comparison Table
| Criteria | Pure Stack | Pure Heap | **Hybrid** |
|----------|------------|-----------|------------|
| **Memory (10 objects)** | 11.2 KB | ~1 KB | **1.8 KB** ✅ |
| **Memory (100 objects)** | ❌ FAIL | ~14 KB | **~14 KB** ✅ |
# Hybrid Architecture Flowchart
**Concept:** Use embedded stack array for small objects, transition to heap only when needed.
**Key Feature:** ⚙️ **Configurable HEAP_THRESHOLD** — tune the stack→heap boundary in `include/memory_config.h` (see [Hybrid Heap Transition](hybrid-heap-transition.md) for details).
---
## Configuration
# Architecture Comparison: Stack vs Heap vs Hybrid
**Goal:** Choose the optimal memory architecture for miniRT world storage based on performance, memory usage, and code complexity.
## Quick Comparison Table
| Criteria | Pure Stack | Pure Heap | **Hybrid** |
|----------|------------|-----------|------------|
| **Memory (10 objects)** | 11.2 KB | ~1 KB | **1.8 KB** ✅ |
| **Memory (100 objects)** | ❌ FAIL | ~14 KB | **~14 KB** ✅ |