A deep dive into QML memory management internals
summary
QML objects are allocated on the process heap and deleted deterministically via the QObject parent tree, while JavaScript values live on a separate V4 32 buckets heap (sizes 16–512B; >512B go to malloc). The V4 heap grows by doubling chunk sizes (now capped at 2MB since Qt 5.3) which used to produce 32–64MB jumps; values shrink from heavy QVariants to 8‑byte QV4 values. Garbage collection runs on the main thread as a stop-the-world mark-and-sweep, can free empty chunks back to the OS since 5.5, and is observable via qv4_mm_stats, Qt Creator profiler, and Valgrind/massif.
AI-written summary · about
chapters (27)
- 0:00Intro
- 3:03Scope
- 4:37Memory management basics
- 5:55Heaps
- 8:05QML and JavaScript
- 8:52QML object types
- 10:16Creating QML objects
- 12:03QML defined properties
- 14:50QML garbage collectors
- 16:44QML objects
- 17:58JavaScript
- 18:50JavaScript type
- 23:54QML growth strategy
- 25:49Garbage collector
- 27:17Mock phase
- 28:34Sweep phase
- 30:24Garbage collector objectives
- 32:11Garbage collector after unloading
- 33:55Wrapup
- 36:05Questions
- 36:37Tools
- 37:36QML stats
- 39:41JavaScript timeline taps
- 40:48More to this
- 42:22Massive
- 44:47Wrap up
- 46:13Conclusion
related talks
31mJavaScript memory management: Visual Guide
27mVisualised guide to memory management in JavaScript
22mThe Hitchhiker's Guide to All Things Memory in JS
28mAlice's Adventures in Memoryland
17mAlice's Adventures in Memory Management, or how JavaScript objects work
21mMemory: Don't Forget to Take Out the Garbage
30mMemory Don't Forget To Take Out The Garbage
24mTrash Talk - Understanding Memory Management
