Package org.robovm.rt

Class GC

java.lang.Object
org.robovm.rt.GC

public class GC
extends Object
Interfaces with the garbage collector
  • Constructor Details

    • GC

      public GC()
  • Method Details

    • getDontExpand

      public static boolean getDontExpand()
      Returns:
      whether this is enabled
    • setDontExpand

      public static void setDontExpand​(boolean value)
      Do not expand the heap unless explicitly requested or forced to
      Parameters:
      value - whether this is enabled
    • getVersion

      public static int getVersion()
      Returns:
      Get the GC library version. The returned value is a constant in the form: ((version_major<<16) | (version_minor<<8) | version_micro).
    • getCount

      public static long getCount()
      Returns:
      Counter incremented per collection. Includes empty GCs at startup.
    • disable

      public static void disable()
      Disable garbage collection. Even GC_gcollect calls will be ineffective.
    • enable

      public static void enable()
      Try to re-enable garbage collection. GC_disable() and GC_enable() calls nest. Garbage collection is enabled if the number of calls to both functions is equal.
    • isDisabled

      public static boolean isDisabled()
      Returns:
      non-zero (TRUE) if and only if garbage collection is disabled (i.e., GC_dont_gc value is non-zero). Does not acquire the lock.
    • getHeapSize

      public static long getHeapSize()
      Returns:
      the number of bytes in the heap. Excludes collector private data structures. Excludes the unmapped memory (returned to the OS). Includes empty blocks and fragmentation loss. Includes some pages that were allocated but never written.
    • getFreeBytes

      public static long getFreeBytes()
      Returns:
      Return a lower bound on the number of free bytes in the heap (excluding the unmapped memory space).
    • getUnmappedBytes

      public static long getUnmappedBytes()
      Returns:
      Return the size (in bytes) of the unmapped memory (which is returned to the OS but could be remapped back by the collector later unless the OS runs out of system/virtual memory).
    • getBytesSinceGC

      public static long getBytesSinceGC()
      Returns:
      Return the number of bytes allocated since the last collection.
    • getTotalBytes

      public static long getTotalBytes()
      Returns:
      Return the total number of bytes allocated in this process. Never decreases, except due to wrapping.
    • collectALittle

      public static void collectALittle()
      Perform some garbage collection work, if appropriate. Return 0 if there is no more work to be done. Typically performs an amount of work corresponding roughly to marking from one page. May do more work if further progress requires it, e.g. if incremental collection is disabled. It is reasonable to call this in a wait loop until it returns 0.
    • getFreeSpaceDivisor

      public static long getFreeSpaceDivisor()
      Returns:
      the current free space divisor
    • setFreeSpaceDivisor

      public static void setFreeSpaceDivisor​(long value)
      We try to make sure that we allocate at least N/GC_free_space_divisor bytes between collections, where N is twice the number of traced bytes, plus the number of untraced bytes (bytes in "atomic" objects), plus a rough estimate of the root set size. N approximates GC tracing work per GC. Initially, GC_free_space_divisor = 3. Increasing its value will use less space but more collection time. Decreasing it will appreciably decrease collection time at the expense of space.
    • getMaxRetries

      public static long getMaxRetries()
      Returns:
      The maximum number of GCs attempted before reporting out of memory after heap expansion fails. Initially 0.
    • setMaxRetries

      public static void setMaxRetries​(long value)
      Parameters:
      value - The maximum number of GCs attempted before reporting out of memory after heap expansion fails. Initially 0.
    • getTimeLimit

      public static long getTimeLimit()
    • setTimeLimit

      public static void setTimeLimit​(long value)
      If incremental collection is enabled, We try to terminate collections after this many milliseconds. Not a hard time bound.
      Parameters:
      value -