# Interface Disposable

All Known Implementing Classes:
  `CanvasFollower, ComputedImage, GestureFollower, ResampledImage`

public interface Disposable
A resource that can be disposed when waiting for the garbage collector would be overly conservative. Invoking the `dispose()` method allows any resources held by this object to be released. The result of calling any other method subsequent to a call to this method is undefined.

Data integrity shall not depend on `dispose()` method invocation. If some data may need to be flushed to a stream or committed to a database, then a `close()` method should be used instead.

## Relationship with `Closeable`

Some classes may implement both the `Disposeable` and `Closeable` interfaces. While very similar, those two interfaces serve slightly different purposes. The `Closeable` interface closes a stream or a connection, but some classes allow the object to be reused with a different stream. However, once an object has been disposed, it cannot be used anymore.
Example: `ImageReader` and `ImageWriter` allow to reuse the same instance many times for reading or writing different images in the same format. New streams can be created, given to the `ImageReader` or `ImageWriter` and closed many times as long as `dispose()` has not been invoked.
Another difference is that `dispose()` does not throw any checked exception. That method may be invoked in a background thread performing cleanup tasks, which would not know what to do in case of failure. Error during `dispose()` execution should not result in any lost of data.

Since:
  0.3
See Also:
  - `Graphics​.dispose()`
  - `ImageReader​.dispose()`
  - `ImageWriter​.dispose()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `dispose()`
  Allows any resources held by this object to be released.

- ## Method Details

  - ### dispose

    void dispose()
    Allows any resources held by this object to be released. The result of calling any other method subsequent to a call to this method is undefined.