Skip to content

detectPluginUnloadLeak

Disables a plugin, checks whether its instance is garbage collected, and enables it again.

The instance is the sentinel: everything a plugin owns is reachable only through it, so a collected instance means the unload released the plugin’s whole graph, and a surviving one means something outside the plugin still holds it. A WeakRef gives an exact answer where a heap measurement would be noisy.

Needs a transport that can force a garbage collection (collectGarbage): desktop, and Android over local adb.

Import:

import { detectPluginUnloadLeak } from 'obsidian-integration-testing';

Signature:

function detectPluginUnloadLeak(params: DetectPluginUnloadLeakParams): Promise<PluginUnloadLeakResult>

Parameters:

Parameter Type Description
params DetectPluginUnloadLeakParams The plugin, whether to enable it again, and transport / vault overrides.

Returns: Promise<PluginUnloadLeakResult> — A Promise resolving to whether the instance leaked.


Links to this page: