Disposable
A base class that implements the IDisposable pattern correctly
Disposable Object ensures proper cleanup of both managed and unmanaged resources. It provides a structured way to handle resource disposal and helps prevent memory leaks in your Unity applications.
do NOT use on MonoBehaviour.
Package Info
display name
AceLand Disposable
package name
latest version
1.0.0
namespace
git repository
dependencies
Features
Automatic disposal state tracking
Separate handling for managed and unmanaged resources
Protection against multiple disposals
Proper implementation of IDisposable pattern
GC optimization through SuppressFinalize
Usage Example
Override DisposeManagedResources
Override this method to clean up managed resources:
Override DisposeUnmanagedResources
Override this method to clean up unmanaged resources:
Best Practices
Always use
usingstatements when possibleCheck
Disposedproperty before operations:
Don't call base methods when overriding:
Handle disposal in a deterministic manner:
Important Considerations
Override
DisposeManagedResourcesfor IDisposable objectsOverride
DisposeUnmanagedResourcesfor native resourcesDon't throw exceptions from Dispose methods
Always check
Disposedstate in public methodsUse try-finally blocks for critical cleanup operations
Last updated