You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implement IDisposable on VirtualizationInstance to prevent zombie processes
VirtualizationInstance holds native ProjFS handles (PRJ_NAMESPACE_VIRTUALIZATION_CONTEXT)
and GCHandles that must be released when the instance is no longer needed. Previously,
StopVirtualizing() had to be called explicitly — if the process crashed or exited without
calling it, ProjFS kept the virtualization root alive, creating zombie processes.
Changes:
- IVirtualizationInstance now extends IDisposable
- VirtualizationInstance implements full dispose pattern:
- Dispose() calls PrjStopVirtualizing, frees GCHandles, frees
Marshal.StringToHGlobalUni notification strings
- Finalizer ~VirtualizationInstance() as safety net
- StopVirtualizing() calls Dispose() for backward compat (Stream.Close pattern)
- Thread-safe: _disposed flag prevents double-free
- All public methods throw ObjectDisposedException after disposal
- Fixed memory leak: _notificationRootStrings and _notificationMappingsHandle
were never freed in StopVirtualizing
- Enabled .NET analyzers (CA1001/CA2213 would have caught this)
- Added 8 unit tests for disposal mechanics (all pass without ProjFS feature)
Version bumped to 2.1.0 (breaking: IVirtualizationInstance now requires Dispose)
0 commit comments