module UI::NativeHandleTracker

Overview

Debug-only handle tracker that monitors NativeHandle lifetimes.

Compiled only when -Dui_debug is passed to the Crystal compiler. In release builds, all tracker calls in NativeHandle are eliminated at compile time via {% if flag?(:ui_debug) %} guards.

Usage

Build with debug tracking:

crystal build my_app.cr -Dui_debug

Dump leaks at shutdown:

at_exit do
  UI::NativeHandleTracker.dump_leaks
end

How It Works

Defined in:

ui/native/handle_tracker.cr

Class Method Summary

Class Method Detail

def self.clear : Nil #

[View source]
def self.dump_leaks(io : IO = STDERR) : Nil #

[View source]
def self.live_count : Int32 #

[View source]
def self.register(handle : NativeHandle) : Nil #

[View source]
def self.unregister(handle : NativeHandle) : Nil #

[View source]