jac-native-memory

Diagnose and fix Jac native memory management errors across RC, ownership, and region modes.

Updated Jul 26, 2026
One-click install
npx skills add https://github.com/PMN123/trapdoor --skill jac-native-memory-pmn123
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: jac-native-memory
Source: https://github.com/PMN123/trapdoor/tree/main/.agents/skills/jac-native-memory
Command: npx skills add https://github.com/PMN123/trapdoor --skill jac-native-memory-pmn123

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Native Jac binaries manage heap memory with reference counting by default, and developers hit cryptic E13xx/E14xx diagnostics, refcount churn, leaks, or fail when building zero-RC binaries. This Skill provides the operational knowledge to interpret those diagnostics, apply ownership annotations, use Region arenas, and verify RC-free builds. ## Core Features & Use Cases - Emit-time GC modes: Choose between --gc cycles (RC plus cycle collector), --gc rc (RC only), and --gc none (no retain/release call sites) when compiling with jac nacompile. - Ownership and borrow checking: Apply opt-in own, &/&mut, and imm annotations, resolve E1301-E1309 diagnostics, and use def drop for deterministic destruction. - Region arenas: Allocate objects inside in <handle> { } blocks for bulk reclamation, move own Region handles across flow boundaries, and respect E1307 boundary rules. - Zero-RC enforced builds: Run --enforce-nogc with --assert-no-rc, fix E1401-E1406 hard errors, and measure coverage with JAC_RC_STATS. - Use Case: A native binary leaks memory under load. Load this Skill to bisect with JAC_NO_GC=1, inspect JAC_RC_STATS output, then annotate hot paths with own/& or move allocations into a Region arena. ## Quick Start Ask the assistant to explain and fix the E1401 error reported when compiling your Jac module with jac nacompile --gc none --enforce-nogc.

Frequently Asked Questions about jac-native-memory

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I build a zero-RC native binary in Jac?

Compile with jac nacompile module.jac --gc none --enforce-nogc --assert-no-rc. Fix the E1401-E1406 errors by annotating contract positions with own, &, &mut, or imm, then verify the build prints assert-no-rc ok.

What do Jac E1301 and E1302 ownership errors mean?

E1301 means you read an own binding after it was moved; reassign it to revive it. E1302 means borrow rules were violated: you may have many live shared borrows or exactly one &mut borrow, never both.

How do Region arenas work in Jac native code?

A Region is a first-class ownable handle opened with in <handle> { }. Everything allocated inside lives in the arena and is reclaimed wholesale when the handle drops, with no ownership discipline required inside the open.

Does Jac ownership annotation affect the Python backend?

Annotations are compile-time-only and erased on the Python backend, where memory stays GC-managed. The drop hook still fires at portable points, but managed(x) is the identity function there.

Why does my Jac native binary leak memory under --gc rc?

The rc mode emits reference counting without a cycle collector, so reference cycles leak. Use the default cycles mode, break cycles with ownership annotations, or move cyclic structures into a Region arena.

How do I measure reference counting overhead in Jac?

Set JAC_RC_STATS=1 when running jac nacompile to print per-module retain, release, and elision counts plus coverage percentage. A fully covered module shows retains=0 releases=0 and is marked rc-free.