4.10.9 nxa
Keywords: onyx

Next: 4.10.10 nxm Up: 4.10 Classes Previous: 4.10.8 nx Contents Index
Subsections

- 4.10.9.1 API

##
4.10.9 nxa

The nxa class implements garbage collection. The garbage collector runs a separate thread that is controlled via an asynchronous message queue.

### 4.10.9.1 API

void * nxa_malloc_e(void *a_arg, size_t a_size, const char *a_filename, uint32_t a_line_num):

void * nxa_malloc(size_t a_size):

  Input(s):
    a_arg:
      Unused.
    a_size:
      Size of memory range to allocate.
    a_filename:
      Should be __FILE__.
    a_line_num:
      Should be __LINE__.
  Output(s):
    retval:
      Pointer to a memory range.
  Exception(s):
    CW_ONYXX_OOM.
  Description:
    malloc() wrapper.

void * nxa_calloc_e(void *a_arg, size_t a_number, size_t a_size, const char *a_filename, uint32_t a_line_num):

void * nxa_calloc(size_t a_number, size_t a_size):

  Input(s):
    a_arg:
      Unused.
    a_number:
      Number of elements to allocate.
    a_size:
      Size of each element to allocate.
    a_filename:
      Should be __FILE__.
    a_line_num:
      Should be __LINE__.
  Output(s):
    retval:
      Pointer to a zeroed memory range.
  Exception(s):
    CW_ONYXX_OOM.
  Description:
    calloc() wrapper.

void * nxa_realloc_e(void *a_arg, void *a_ptr, size_t a_size, size_t a_old_size, const char *a_filename, uint32_t a_line_num):

void * nxa_realloc(void *a_ptr, size_t a_size, size_t a_old_size):

  Input(s):
    a_arg:
      Unused.
    a_ptr:
      Pointer to memory range to be reallocated.
    a_size:
      Size of memory range to allocate.
    a_old_size:
      Size of memory range previously pointed to by a_ptr.
    a_filename:
      Should be __FILE__.
    a_line_num:
      Should be __LINE__.
  Output(s):
    retval:
      Pointer to a memory range.
  Exception(s):
    CW_ONYXX_OOM.
  Description:
    realloc() wrapper.

void * nxa_free_e(void *a_arg, void *a_ptr, size_t a_size, const char *a_filename, uint32_t a_line_num):

void * nxa_free(void *a_ptr, size_t a_size):

  Input(s):
    a_arg:
      Unused.
    a_ptr:
      Pointer to to memory range to be freed.
    a_size:
      Sizef of memory range pointed to by a_ptr.
    a_filename:
      Should be __FILE__.
    a_line_num:
      Should be __LINE__.
  Output(s):
    None.
  Exception(s):
    None.
  Description:
    free() wrapper.

void nxa_collect(void):

  Input(s):
    None.
  Output(s):
    None.
  Exception(s):
    CW_ONYXX_OOM.
  Description:
    Force an asynchronous garbage collection.

bool nxa_active_get(void):

  Input(s):
    None.
  Output(s):
    retval:
      false:
        Garbage collector deactivated.
      true:
        Garbage collector active.
  Exception(s):
    None.
  Description:
    Return whether the garbage collector is active (runnable).

void nxa_active_set(bool a_active):

  Input(s):
    a_active:
      false:
        Deactivate garbage collector.
      true:
        Activate garbage collector.
  Output(s):
    None.
  Exception(s):
    CW_ONYXX_OOM.
  Description:
    Send a message to the garbage collector to activate or deactivate. The asynchronous nature of the message means that it is possible for the garbage collector to run after this function returns, even if a deactivation message has been sent.

cw_nxoi_t nxa_period_get(void):

  Input(s):
    None.
  Output(s):
    retval:
      Current inactivity period in seconds that the garbage collector waits before doing a collection.
  Exception(s):
    None.
  Description:
    Return the current inactivity period in seconds that the garbage collector waits before doing a collection.

void nxa_period_set(cw_nxoi_t a_period):

  Input(s):
    a_period:
      Inactivity period in seconds that the garbage collector should wait before doing a collection. If 0, the garbage collector will never run due to inactivity.
  Output(s):
    None.
  Exception(s):
    CW_ONYXX_OOM.
  Description:
    Set the inactivity period in seconds that the garbage collector should wait before doing a collection.

cw_nxoi_t nxa_threshold_get(void):

  Input(s):
    None.
  Output(s):
    retval:
      Number of bytes of memory allocated since the last garbage collection that will trigger the garbage collector to run.
  Exception(s):
    None.
  Description:
    Return the number of bytes of memory allocated since the last garbage collection that will trigger the garbage collector to run.

void nxa_threshold_set(cw_nxoi_t a_threshold):

  Input(s):
    a_threshold:
      The number of bytes of memory allocated since the last garbage collection that will trigger the garbage collector to run.
  Output(s):
    None.
  Exception(s):
    CW_ONYXX_OOM.
  Description:
    Set the number of bytes of memory allocated since the last garbage collection that will trigger the garbage collector to run.

void nxa_stats_get(cw_nxoi_t *r_collections, cw_nxoi_t *r_count, cw_nxoi_t *r_ccount, cw_nxoi_t *r_cmark, cw_nxoi_t *r_mcount, cw_nxoi_t *r_mmark, cw_nxoi_t *r_scount, cw_nxoi_t *r_smark):

  Input(s):
    r_collections:
      Pointer to an integer.
    r_count:
      Pointer to an integer.
    r_ccount:
      Pointer to an integer.
    r_cmark:
      Pointer to an integer.
    r_mcount:
      Pointer to an integer.
    r_mmark:
      Pointer to an integer.
    r_scount:
      Pointer to an integer.
    r_smark:
      Pointer to an integer.
  Output(s):
    *r_collections:
      Number of times the garbage collector has run.
    *r_count:
      Current number of bytes of memory allocated.
    *r_ccount:
      Number of bytes of memory allocated as of the end of the most recent garbage collection.
    *r_cmark:
      Number of microseconds spent in the mark phase of the most recent garbage collection.
    *r_mcount:
      Largest number of bytes of memory ever allocated at any point in time.
    *r_mmark:
      Largest number of microseconds ever spent in the mark phase of a garbage collection.
    *r_scount:
      Total number of bytes of memory ever allocated.
    *r_smark:
      Total number of microseconds spent in the mark phase of all garbage collections.
  Exception(s):
    None.
  Description:
    Return garbage collector statistics.

Next: 4.10.10 nxm Up: 4.10 Classes Previous: 4.10.8 nx Contents Index