# 0.6.6: Memory Management Improvements

DevFeed: [0.6.6: Memory Management Improvements](<https://devfeed.tech/articles/0-6-6-memory-management-improvements-22390.md>)

Original publisher: [Read original article](<https://www.red-lang.org/2025/03/066-memory-management-improvements.html>)

Author: Nenad Rakocevic (noreply@blogger.com)

Published: 2025-03-19T16:11:00Z

Content type: release

Language: en

Sources: [Red](<https://devfeed.tech/sources/red.md>)

Topics: [Red](<https://devfeed.tech/topics/red.md>), [Compiler](<https://devfeed.tech/topics/compiler.md>)

Tags: [gc](<https://devfeed.tech/tags/gc.md>), [improvements](<https://devfeed.tech/tags/improvements.md>), [memory](<https://devfeed.tech/tags/memory.md>), [memory-management](<https://devfeed.tech/tags/memory-management.md>), [release](<https://devfeed.tech/tags/release.md>)

## AI overview

Red 0.6.6 introduces low-level memory-management and garbage-collection improvements. The release adds management for unused external resources such as image buffers and font handles, and replaces conservative native-stack scanning with a more precise approach supported by compiler-generated frame hints.

## Source excerpt

This new milestone brings many low-level improvements to Red's memory management and garbage collecting. Most of those are long-planned additions needed to complete the internal memory model and make it robust enough for the future stable Red v1.0. First, here is a simplified overview of the Red memory model (existing parts in green color, new parts in orange, non-Red parts in blue): All Red values are stored in series. Some Red values require one or more buffers to hold their content. The values can never reference a buffer directly, but only through a node reference, to enable relocation when expanding the series buffer or when moving it around during compaction by the GC. Now let's dive into the hairy details! External resources GC The Red/View engine backends rely on external resources provided by the OS. Among those resources, some are linked to face! or font! object and require special care when those objects are not reachable anymore. So far, our GC (Garbage Collector) was not able to release such resources (images bitmap buffers and fonts handles), as unreachable Red aggregate values are seeing as simple series during the sweeping GC stage. In order to improve that, we have added an external resources manager, that will track and free unused resources, allowing now unrestricted images and fonts usage! Accurate GC The Red GC relies on allocated memory walking and native stack scanning to identify live Red values. Scanning the native stack can be challenging. The scanner used so far a conservative approach, which is simpler, but can lead to corruptions or crashes in rare cases (e.g. a floating point number being mistaken for a series or node pointer). Moreover, such approach precluded from having a nodes frame GC, as there was no way to accurately identify node pointers on the stack. This is now solved. The plan was always to make it precise when getting closer to a Red v1.0 and that's what we did in this release. In order to achieve that, several key addition