org.apache.cassandra.io.util

## Class SafeMemory

- java.lang.Object
- - org.apache.cassandra.io.util.Memory
  - - org.apache.cassandra.io.util.SafeMemory

All Implemented Interfaces:
  java.lang.AutoCloseable, SharedCloseable

    public class SafeMemory
    extends Memory
    implements SharedCloseable

### Field Summary

### Fields inherited from class org.apache.cassandra.io.util.Memory

`NO_BYTE_BUFFERS, peer, size`

### Constructor Summary

Constructors
Constructor and Description
`SafeMemory(long size)`

### Method Summary

All Methods Instance Methods Concrete Methods
`protected void` `checkBounds(long start, long end)`
`void` `close()`
`java.lang.Throwable` `close(java.lang.Throwable accumulate)`
`SafeMemory` `copy(long newSize)`
`void` `free()`
`SafeMemory` `sharedCopy()`

### Methods inherited from class org.apache.cassandra.io.util.Memory

`allocate, asByteBuffer, asByteBuffers, equals, getByte, getBytes, getInt, getLong, put, setByte, setByteBuffer, setBytes, setBytes, setInt, setLong, setMemory, setShort, size, toString, toString`

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Constructor Detail

#### SafeMemory

    public SafeMemory(long size)

### Method Detail

#### sharedCopy

    public SafeMemory sharedCopy()

Specified by:
  `sharedCopy` in interface `SharedCloseable`
Returns:
  a new instance of the object representing the same state and backed by the same underlying resources. Coordinates with the original (and other instances) when the underlying resource should be closed. Throws an exception if the shared resource has already been closed.

#### free

    public void free()

Overrides:
  `free` in class `Memory`

#### close

    public void close()

Specified by:
  `close` in interface `java.lang.AutoCloseable`
Overrides:
  `close` in class `Memory`

#### close

    public java.lang.Throwable close(java.lang.Throwable accumulate)

Specified by:
  `close` in interface `SharedCloseable`

#### copy

    public SafeMemory copy(long newSize)

Overrides:
  `copy` in class `Memory`

#### checkBounds

    @Inline
    protected void checkBounds(long start,
                                       long end)

Overrides:
  `checkBounds` in class `Memory`