Skip to content

[NativeAOT] Stabilize DoNotLeakWeakReferences by runtime-specific surfaced-object tolerance - #11754

Closed
simonrozsival with Copilot wants to merge 2 commits into
mainfrom
copilot/investigate-failing-donotleakweakreferences
Closed

[NativeAOT] Stabilize DoNotLeakWeakReferences by runtime-specific surfaced-object tolerance#11754
simonrozsival with Copilot wants to merge 2 commits into
mainfrom
copilot/investigate-failing-donotleakweakreferences

Conversation

Copilot AI commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

DoNotLeakWeakReferences is intermittently failing under NativeAOT because Runtime.GetSurfacedObjects() can include higher transient process-global noise than the previous assertion window allowed. The test should continue detecting real leaks without failing on runtime-specific baseline drift.

  • Test assertion robustness

    • Keep existing tolerance for non-NativeAOT runs (±10).
    • Use a wider tolerance only when Microsoft.Android.Runtime.RuntimeFeature.IsNativeAotRuntime is enabled (±30).
    • Apply this tolerance to both in-thread (#2) and post-GC (#3) surfaced-object count assertions.
  • Behavioral intent

    • Preserve strict leak detection semantics across runtimes.
    • Reduce false negatives caused by NativeAOT-specific transient surfaced-object churn.
const int defaultTolerance = 10;
const int nativeAotTolerance = 30;
int tolerance = AppContext.TryGetSwitch (
	"Microsoft.Android.Runtime.RuntimeFeature.IsNativeAotRuntime",
	out bool isNativeAotRuntime) && isNativeAotRuntime
	? nativeAotTolerance
	: defaultTolerance;

Co-authored-by: simonrozsival <374616+simonrozsival@users.noreply.github.com>
Copilot AI changed the title [WIP] Investigate failing DoNotLeakWeakReferences issue [NativeAOT] Stabilize DoNotLeakWeakReferences by runtime-specific surfaced-object tolerance Jun 26, 2026
Copilot AI requested a review from simonrozsival June 26, 2026 12:41
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 27, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[NativeAOT] Investigate failing DoNotLeakWeakReferences

2 participants