In addition to borrowed-references, Cone also supports region-managed references. Region-managed references are also pointers to values and are constrained by permissions, both static and lock.

The key difference is that every region-managed reference belongs to a memory region in the heap which manages the ways its values are allocated and freed. This is in contrast to a borrowed reference, which has no idea which memory region holds the value it points to.

What is a Region?

Until now, the values we have worked with have all been stored in global and local variables:

When we want to dynamically allocate memory for a value during runtime that we need to survive beyond the scope it is allocated in, neither global and local variables can handle this requirement. This is when we need to make use of the "heap", the large amount of free memory available to use outside of what has been reserved for global variables, code and any stacks.

Unusual among languages, Cone conceptually partitions the heap into regions. Each region has its own strategy for allocating and automatically reclaiming memory that holds values. Every program value on the heap is wholly located within and governed by its owning region.

The reason Cone supports multiple regions is because there is no one perfect strategy for allocating and automatically freeing memory. Each strategy (e.g., tracing GC, ref-counting, single-owner, pools or arenas) carries different trade-offs in terms of throughput, latency/responsiveness, memory use and leakage, data structure flexibility, and programmer convenience.

Instead of restricting a program to the limitations of only one memory management strategy, as most languages do, Cone dynamically partitions memory into regions, each with its own approach to memory allocation and collection. For every new data object, Cone allows the programmer to specify, at allocation time, which region the object belongs to, according to how well it matches the object's usage profile.

Owning vs. Weak References

There are two kinds of region-managed references: