Next: , Previous: Object allocation, Up: About CNI


11.9 Memory allocation

When allocating memory in CNI methods it is best to handle out-of-memory conditions by throwing a Java exception. These functions are provided for that purpose:

— Function: void* JvMalloc (jsize size)

Calls malloc. Throws java.lang.OutOfMemoryError if allocation fails.

— Function: void* JvRealloc (void* ptr, jsize size)

Calls realloc. Throws java.lang.OutOfMemoryError if reallocation fails.

— Function: void JvFree (void* ptr)

Calls free.