Skip to content

Never dispose the native statics - #1863

Merged
mattleibow merged 1 commit into
mainfrom
dev/never-dispose
Nov 15, 2021
Merged

mattleibow merged 1 commit into
mainfrom
dev/never-dispose

Conversation

@mattleibow

Copy link
Copy Markdown
Contributor

Description of Change

When the AppDomain is unloaded, the runtime will try to dispose all instances, including ones on static fields. This might never happen in a single app, however, during test runs or potentially IDE integrations, the AppDomain is unloaded, the instances are collected and then SkiaSharp statics try to dispose of the native statics.

I originally had code to prevent the user from disposing the instances, however, the GC still runs and is still able to collect. So, for these few instances we mark it that we do not own the handles (which we don't) and then never even try clean up the instances. The GC will get to it.

Bugs Fixed

API Changes

Behavioral Changes

PR Checklist

  • Has tests (if omitted, state reason in description)
  • Rebased on top of main at time of PR
  • Changes adhere to coding standard
  • Updated documentation

@mattleibow
mattleibow merged commit b87980d into main Nov 15, 2021
@mattleibow
mattleibow deleted the dev/never-dispose branch November 15, 2021 19:24
mattleibow added a commit that referenced this pull request Jul 3, 2026
Expand the skill's scan taxonomy from 6 to 12 families, each backed by a
real historical SkiaSharp leak fix (finalizer/collection ordering #3796/#3291,
Clone double-free #2904, disposing native statics #1863/#4080/#1224,
field-not-nulled #1256/#1344, stream/callback/delegate-proxy lifetime
#3589/#2916/#996, allocation-failure #1784/#1642). Broaden Phase 1.3 de-dup to
search by api/type name (real leaks are filed as [BUG], not [memory-leak]) and
add the Blob.FromStream / PR #3473 worked example. Extend the Phase 3.2 fix
table to cover all 12 families. Document two verified, un-filed family-6
candidates surfaced by a model-diverse scan (SKRegion.SpanIterator missing
parent ref; SKPixmap.ExtractSubset/With* not propagating pixelSource).

Co-authored-by: Copilot App <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant