internal void AddFinalizedObject(IPyDisposable obj) { if (!Enable) { return; } #if FINALIZER_CHECK lock (_queueLock) #endif { this._objQueue.Enqueue(obj); } }
internal void AddFinalizedObject(IPyDisposable obj) { if (!Enable) { return; } if (Runtime.Py_IsInitialized() == 0) { // XXX: Memory will leak if a PyObject finalized after Python shutdown, // for avoiding that case, user should call GC.Collect manual before shutdown. return; } #if FINALIZER_CHECK lock (_queueLock) #endif { _objQueue.Enqueue(obj); } GC.ReRegisterForFinalize(obj); if (!_pending && _objQueue.Count >= Threshold) { AddPendingCollect(); } }
public FinalizationException(string message, IPyDisposable disposable, Exception innerException) : base(message, innerException) { this.Disposable = disposable ?? throw new ArgumentNullException(nameof(disposable)); }