memory-and-disposal

Manage brepjs WASM handle disposal with using and DisposalScope.

77|7|Updated Feb 1, 2026
One-click install
npx skills add https://github.com/andymai/brepjs --skill memory-and-disposal
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: memory-and-disposal
Source: https://github.com/andymai/brepjs/tree/main/.claude/skills/memory-and-disposal
Command: npx skills add https://github.com/andymai/brepjs --skill memory-and-disposal

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

WASM objects used by brepjs are not tracked by the JavaScript garbage collector, so un-disposed shape and kernel handles cause silent, growing memory leaks that can crash browser-based CAD applications without warning.

Core Features & Use Cases

  • Deterministic Handle Cleanup: Guides use of the using keyword, DisposalScope, and scoped helper functions to ensure all WASM handles are freed predictably at the end of their lifetime.
  • Leak Detection Workflow: Provides step-by-step instructions for using getDisposalStats to identify missing disposal calls, peak handle accumulation, and FinalizationRegistry-reclaimed handles.
  • Kernel-Specific Guidance: Explains the critical difference between occt-wasm arena memory (freed only via kernel dispose calls) and Embind kernel memory (freed directly via handle delete) to debug leaks that only appear on one kernel.
  • Use Case: Use this skill when writing new brepjs *Fns.ts operations, debugging unexplained memory growth in the browser playground, or enforcing the require-using-for-handles pattern checker rule in CI.

Quick Start

Use the memory-and-disposal skill to audit your new brepjs operation code for missing handle disposal calls and fix any WASM memory leak risks.

Frequently Asked Questions about memory-and-disposal

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

FAQPage Schema
Why does my brepjs WASM application have a silent memory leak?

brepjs WASM memory leaks occur because shape and kernel handles are invisible to JavaScript garbage collection, requiring explicit disposal calls to free allocated WebAssembly memory.

How do I debug unexplained memory growth in a browser CAD application?

Debug unexplained memory growth by using getDisposalStats to identify missing disposal calls, peak handle accumulation, and FinalizationRegistry-reclaimed handles in your CAD application.

What's the best way to clean up WASM handles in brepjs operations?

The best way to clean up WASM handles is using the using keyword, DisposalScope, and scoped helper functions to ensure deterministic disposal at the end of handle lifetimes.

How do occt-wasm arena memory and Embind kernel memory differ in disposal behavior?

occt-wasm arena memory is freed only via kernel dispose calls, whereas Embind kernel memory is freed directly via handle delete, causing leaks that appear on only one kernel.

Can I enforce handle disposal rules in my CI pipeline?

Yes, you can enforce deterministic cleanup in CI by applying the require-using-for-handles pattern checker rule to verify all brepjs operations include proper handle disposal calls.

When do I need to audit brepjs operation code for missing handle disposal?

Audit brepjs operation code for missing handle disposal when writing new *Fns.ts operations or debugging unexplained memory growth to prevent silent WASM leaks that crash applications.