Last Updated on August 5, 2026

Overview

Optimizing flash storage size [The Flash Footprint of Hello World: Comparing Yocto Package Dependencies] is only half the battle in resource-constrained embedded systems; runtime memory usage is equally critical. While a “Hello World” application seems trivial, its execution behavior changes dramatically depending on the software ecosystem. This post analyzes data from a structured runtime evaluation under Yocto, breaking down how heap growth, memory-mapped allocations, and system protections inflate the real RAM requirement of various programming environments.

Key Takeaways

  • Low-Level Programming Language Execution:
    • C, C++, and Rust applications execute with minimal memory overhead, requiring less than 2.5 MB of actual RAM.
  • The Cost of Multithreading:
    • Adding basic concurrency primitives (like POSIX threads in C++) spikes active memory map requirements immediately.
  • Virtual Space vs. Real RAM:
    • Languages like Go and Node.js allocate massive virtual memory regions, heavily distorting simple system monitoring metrics.
  • Interpreter vs. JIT Bloat:
    • Python requires hundreds of megabytes of heap allocation, while Node.js relies heavily on memory maps and page modifications.

Case Studies: Real-World Runtime Memory Consumption

The metrics below outline the components that compile into the estimated real RAM usage of each application environment.

Comprehensive Runtime RAM Allocation Metrics

Application NameTrue Heap Growth (brk)Immediate Active MapsActivated via mprotectEstimated Real RAM UsageIgnored Virtual Memory Space
95.02_hello-cmake0.61 MB0.03 MB0.02 MB0.67 MB1.78 MB
95.21_rust-hello-world1.63 MB0.06 MB0.04 MB1.73 MB2.03 MB
95.01_hello-cpp2.14 MB0.07 MB0.10 MB2.30 MB5.55 MB
95.04_hello-cmake-pthread1.92 MB8.10 MB0.02 MB10.04 MB1.78 MB
95.24_python-poetry-hw4.69 MB7.59 MB0.47 MB12.75 MB15.65 MB
95.25_golang-helloworld0.00 MB43.46 MB0.00 MB43.46 MB1161.12 MB
95.22_npm-hello-world10.09 MB58.79 MB267.86 MB336.75 MB1185.97 MB
95.23_npm-reg-international6.65 MB70.84 MB267.68 MB345.17 MB1250.03 MB
95.17_hello-python3448.53 MB2.68 MB0.41 MB451.61 MB11.43 MB

Technical Breakdown: Memory Mechanics

1. The Multithreading Penalty

Comparing hello-cmake to hello-cmake-pthread highlights a critical concept: concurrency costs physical memory. Simply linking and deploying POSIX threads forces immediate active map creation, driving the real RAM usage up from 0.67 MB to 10.04 MB. This is primarily caused by the thread scheduler pre-allocating memory structures and individual thread stack spaces.

2. “Virtual Memory Deception” (Go and Node.js)

The term “Virtual Memory Deception” perfectly captures the illusion uncovered in our technical breakdown. It highlights a critical concept in computer science: allocated (or virtual) memory size does not equal actual physical memory impact.

What do profiling tools or operating systems report about memory? They often blend Virtual Memory Size (VIRT) and Resident Set Size (RSS), leading to highly deceptive conclusions about memory usage. In our tests, relevant system calls were traced with perf, and a small utility was written to analyze this.

Go and Node.js utilize virtual memory tricks that can startle administrators looking at basic system logs. Go reports 0 MB of standard heap growth via the traditional data segment allocator (brk) but registers 43.46 MB of Immediate Active Maps alongside over 1.1 GB of Ignored Virtual Space. Node.js environments amplify this behavior further. They are claiming upwards of 1.2 GB of virtual space to manage their execution pools and runtime structures.

3. The Python Interpreter Paradox

Standard Python scripts present an inverse memory architecture compared to Node.js. Rather than using memory maps protected via mprotect flags, hello-python3 experiences staggering heap consumption, utilizing 448.53 MB of True Heap Growth just to initialize the environment loop and interpret a base script. Conversely, packaging that script via poetry structures changes the allocation strategy completely, shifting the weight to active memory mapping engines and lowering estimated RAM to 12.75 MB.

The paradox describes a very specific technical phenomenon: how the operating system loads code into memory at the exact millisecond of startup. However, in a real-world application, this initial advantage quickly disappears.

3.1. The Startup Mechanism (Why the Paradox Happens)

The massive gap in “True Heap Growth” during initialization comes down to how Python finds, parses, and loads code into RAM.

  • The Raw Python Script (448.53 MB Heap):
    • When you run a loose, unstructured Python script, the CPython interpreter has to parse the raw text files, build Abstract Syntax Trees (AST), compile them to bytecode in real-time, and dynamically allocate namespace dictionaries in the active heap memory. If you are using deep memory profiling tools, you will see a massive spike in heap allocation because Python is doing heavy structural work just to prepare the script loop.
  • The Poetry-Packaged Script (12.75 MB Estimated Real RAM):
    • When you use Poetry, you are forced to structure your code as a proper Python package with a pyproject.toml and to define [tool.poetry.scripts] entry points. When installed this way, Python pre-compiles the bytecode (.pyc files). At startup, the operating system uses its Memory-Mapping engine (mmap) to map these files directly from the root file system into virtual memory. The active heap remains untouched, resulting in that incredibly low 12.75 MB baseline initialization figure.

3.2. Why This Advantage Disappears at Runtime

While Poetry forces a structured architecture that achieves a beautiful 12.75 MB startup baseline, this is a temporary illusion once your application actually starts doing work.

  • Data Belongs to the Heap:
    • Memory mapping (mmap) only optimizes how the code itself is loaded. The moment your application processes a web request, parses a JSON string, or loads a database query, Python must allocate that dynamic data inside the true heap.
  • The Library Equalizer:
    • If your script imports massive third-party libraries (like FastAPI, Pandas, or NumPy), those libraries will bypass the mmap optimization to allocate their heavy C-extensions directly into the RAM. Whether you deployed with pip ⁣or Poetry, a 500 MB NumPy array will still consume exactly 500 MB of RAM.
  • Not Exclusive to “Poetry”:
    • This memory-mapping trick is a feature of the Python interpreter, not a secret technology owned by Poetry. If you take that same structured project and install it using standard Python tools via pip install -e . (editable mode) inside a standard virtual environment (venv), you will achieve the same low memory-mapped initialization layout.

3.3 The Python Interpreter Paradox Summary

Metric / PhaseUnstructured Raw ScriptProperly Packaged Project (Poetry / Pip setup)
Startup Heap (Code Loading)High (Dynamic Heap compilation)Extremely Low (OS Memory Mapping / 12.75 MB)
Runtime Heap (Processing Data)HighIdentical (High)


The paradox perfectly describes the architectural difference in how the OS handles package entry points versus raw files. However, for a running application that processes data over time, Poetry does not grant you a magical memory discount.

Practical Conclusion

A runtime environment that performs flawlessly on a server or developer workstation can exhaust the memory resources of an industrial target board. Applications built with Node.js and standard Python environments risk pushing small-footprint platforms into out-of-memory (OOM) crashing loops. Selecting a language stack must be evaluated against physical hardware capacities from day one of development.

Appendix

To learn how Embedded-Linux works, take a look here. To learn more about the Yocto Project®, take a look here.

Upcoming Events

Our 3 points

of differentiation

We provide host and target hardware during all our teaching.

Three or more people from the same company? We provide private customized training – consulting included.

Subject matter experts develop high-quality, job-related, up-to-date, authentic courseware.

Reliable Embedded Systems
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.