RefCountedMemory (apache-cassandra API)
Date: 2014-10-21

org.apache.cassandra.cache

## Class RefCountedMemory

- java.lang.Object
- - org.apache.cassandra.io.util.Memory
  - - org.apache.cassandra.cache.RefCountedMemory

- All Implemented Interfaces:
    java.lang.AutoCloseable

      public class RefCountedMemory
      extends Memory
      implements java.lang.AutoCloseable

- - ### Field Summary

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

      `peer`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `RefCountedMemory(long size)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()`
    `RefCountedMemory` | `copy(long newSize)`
    `void` | `free()`
    `boolean` | `reference()`
    `void` | `unreference()` decrement reference count.

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

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

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

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

- - ### Constructor Detail

    - #### RefCountedMemory

          public RefCountedMemory(long size)

  - ### Method Detail

    - #### reference

          public boolean reference()

      Returns:
        true if we succeed in referencing before the reference count reaches zero. (A FreeableMemory object is created with a reference count of one.)

    - #### unreference

          public void unreference()

      decrement reference count. if count reaches zero, the object is freed.

    - #### copy

          public RefCountedMemory copy(long newSize)

      Overrides:
        `copy` in class `Memory`

    - #### free

          public void free()

      Overrides:
        `free` in class `Memory`

    - #### close

          public void close()

      Specified by:
        `close` in interface `java.lang.AutoCloseable`

Copyright © 2014 The Apache Software Foundation