Memory Advice main interface
The main interface to use Memory Advice.
Summary
Enumerations |
|
---|---|
MemoryAdvice_ErrorCode{
|
enum All the error codes that can be returned by MemoryAdvice functions. |
MemoryAdvice_MemoryState{
|
enum All possible memory states that can be reported by the library. |
Typedefs |
|
---|---|
MemoryAdvice_ErrorCode
|
typedef All the error codes that can be returned by MemoryAdvice functions. |
MemoryAdvice_MemoryState
|
typedef All possible memory states that can be reported by the library. |
MemoryAdvice_WatcherCallback)(MemoryAdvice_MemoryState state, void *user_data)
|
typedefvoid(*
|
Functions |
|
---|---|
MemoryAdvice_getAvailableMemory()
|
int64_t
Calculates an estimate for the amount of memory that can safely be allocated, int bytes.
|
MemoryAdvice_getMemoryState()
|
Returns the current memory state.
|
MemoryAdvice_getPercentageAvailableMemory()
|
float
Calculates an estimate for the amount of memory that can safely be allocated, as a percentage of the total memory.
|
MemoryAdvice_getTotalMemory()
|
int64_t
Calculates the total memory available on the device, as reported by ActivityManager::getMemoryInfo()
|
MemoryAdvice_init(JNIEnv *env, jobject context)
|
Initialize the Memory Advice library.
|
MemoryAdvice_initWithParams(JNIEnv *env, jobject context, const char *params)
|
Initialize the Memory Advice library.
|
MemoryAdvice_registerWatcher(uint64_t intervalMillis, MemoryAdvice_WatcherCallback callback, void *user_data)
|
Registers a watcher that polls the Memory Advice library periodically, and invokes the watcher callback when the memory state goes critical.
|
MemoryAdvice_unregisterWatcher(MemoryAdvice_WatcherCallback callback)
|
Removes all watchers with the given callback that were previously registered using MemoryAdvice_registerWatcher.
|
Macros |
|
---|---|
MEMORY_ADVICE_BUGFIX_VERSION 0
|
|
MEMORY_ADVICE_MAJOR_VERSION 2
|
|
MEMORY_ADVICE_MINOR_VERSION 1
|
|
MEMORY_ADVICE_PACKED_VERSION ANDROID_GAMESDK_PACKED_VERSION(TUNINGFORK_MAJOR_VERSION, \
TUNINGFORK_MINOR_VERSION, \
TUNINGFORK_BUGFIX_VERSION)
|
Enumerations
MemoryAdvice_ErrorCode
MemoryAdvice_ErrorCode
All the error codes that can be returned by MemoryAdvice functions.
MemoryAdvice_MemoryState
MemoryAdvice_MemoryState
All possible memory states that can be reported by the library.
Typedefs
MemoryAdvice_ErrorCode
enum MemoryAdvice_ErrorCode MemoryAdvice_ErrorCode
All the error codes that can be returned by MemoryAdvice functions.
MemoryAdvice_MemoryState
enum MemoryAdvice_MemoryState MemoryAdvice_MemoryState
All possible memory states that can be reported by the library.
MemoryAdvice_WatcherCallback
void(* MemoryAdvice_WatcherCallback)(MemoryAdvice_MemoryState state, void *user_data)
Functions
MemoryAdvice_getAvailableMemory
int64_t MemoryAdvice_getAvailableMemory()
Calculates an estimate for the amount of memory that can safely be allocated, int bytes.
Details | |
---|---|
Returns |
A positive number with an estimate of the percentage memory available.
|
Returns |
MEMORYADVICE_ERROR_NOT_INITIALIZED (a negative number) if Memory Advice was not yet initialized.
|
MemoryAdvice_getMemoryState
MemoryAdvice_MemoryState MemoryAdvice_getMemoryState()
Returns the current memory state.
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
A MemoryAdvice_MemoryState, if successful,
|
||
Returns |
MEMORYADVICE_ERROR_NOT_INITIALIZED (a negative number) if Memory Advice was not yet initialized.
|
MemoryAdvice_getPercentageAvailableMemory
float MemoryAdvice_getPercentageAvailableMemory()
Calculates an estimate for the amount of memory that can safely be allocated, as a percentage of the total memory.
Details | |
---|---|
Returns |
A positive number between 0 and 100 with an estimate of the percentage memory available.
|
Returns |
MEMORYADVICE_ERROR_NOT_INITIALIZED (a negative number) if Memory Advice was not yet initialized.
|
MemoryAdvice_getTotalMemory
int64_t MemoryAdvice_getTotalMemory()
Calculates the total memory available on the device, as reported by ActivityManager::getMemoryInfo()
Details | |
---|---|
Returns |
The total memory of the device, in bytes.
|
Returns |
MEMORYADVICE_ERROR_NOT_INITIALIZED (a negative number) if Memory Advice was not yet initialized.
|
MemoryAdvice_init
MemoryAdvice_ErrorCode MemoryAdvice_init( JNIEnv *env, jobject context )
Initialize the Memory Advice library.
This must be called before any other functions.
This version of the init function will use the library provided default params.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
||||
Returns |
MEMORYADVICE_ERROR_OK if successful,
|
||||
Returns |
MEMORYADVICE_ERROR_ALREADY_INITIALIZED if Memory Advice was already initialized.
|
MemoryAdvice_initWithParams
MemoryAdvice_ErrorCode MemoryAdvice_initWithParams( JNIEnv *env, jobject context, const char *params )
Initialize the Memory Advice library.
This must be called before any other functions.
This version of the init function will read the given params instead of using the library provided default params. The format of params is a JSON string with a semantic like default.json in the root directory of this library.
Details | |||||||
---|---|---|---|---|---|---|---|
Parameters |
|
||||||
Returns |
MEMORYADVICE_ERROR_OK if successful,
|
||||||
Returns |
MEMORYADVICE_ERROR_ADVISOR_PARAMETERS_INVALID if the provided parameters are not a valid JSON object,
|
||||||
Returns |
MEMORYADVICE_ERROR_ALREADY_INITIALIZED if Memory Advice was already initialized.
|
MemoryAdvice_registerWatcher
MemoryAdvice_ErrorCode MemoryAdvice_registerWatcher( uint64_t intervalMillis, MemoryAdvice_WatcherCallback callback, void *user_data )
Registers a watcher that polls the Memory Advice library periodically, and invokes the watcher callback when the memory state goes critical.
This function creates another thread that calls MemoryAdvice_getMemoryState every intervalMillis
milliseconds. If the returned state is not MEMORYADVICE_STATE_OK, then calls the watcher callback with the current state.
Details | |||||||
---|---|---|---|---|---|---|---|
Parameters |
|
||||||
Returns |
MEMORYADVICE_ERROR_OK if successful,
|
||||||
Returns |
MEMORYADVICE_ERROR_NOT_INITIALIZED if Memory Advice was not yet initialized,
|
MemoryAdvice_unregisterWatcher
MemoryAdvice_ErrorCode MemoryAdvice_unregisterWatcher( MemoryAdvice_WatcherCallback callback )
Removes all watchers with the given callback that were previously registered using MemoryAdvice_registerWatcher.
Details | |
---|---|
Returns |
MEMORYADVICE_ERROR_OK if successful,
|
Returns |
MEMORYADVICE_ERROR_NOT_INITIALIZED if Memory Advice was not yet initialized.
|
Returns |
MEMORYADVICE_ERROR_WATCHER_NOT_FOUND if the given callback wasn't previously registered.
|
Macros
MEMORY_ADVICE_BUGFIX_VERSION
MEMORY_ADVICE_BUGFIX_VERSION 0
MEMORY_ADVICE_MAJOR_VERSION
MEMORY_ADVICE_MAJOR_VERSION 2
MEMORY_ADVICE_MINOR_VERSION
MEMORY_ADVICE_MINOR_VERSION 1
MEMORY_ADVICE_PACKED_VERSION
MEMORY_ADVICE_PACKED_VERSION ANDROID_GAMESDK_PACKED_VERSION(TUNINGFORK_MAJOR_VERSION, \ TUNINGFORK_MINOR_VERSION, \ TUNINGFORK_BUGFIX_VERSION)