# RPC Exports for malloc_test

## mt.mem_alloc

Allocates the specified number of bytes (debugging/test function). Use b|k|m|g to specify the desired size unit

## mt.mem_free

Frees the specified number of bytes, previously allocated by one of the other malloc_test functions (e.g. mt.mem_alloc or the script mt_mem_alloc). Use b|k|m|g to specify the desired size unit. Returns the number of bytes freed (can be higher or smaller than the requested size)

## mt.mem_realloc

Reallocates the specified number of bytes from a pre-allocated randomly selected memory chunk. If no pre-allocated memory chunks exists, it will fail. Make sure mt.mem_used is non 0 or call mt.mem_alloc prior to calling this function. Returns the difference in bytes (<0 if bytes were freed, >0 if more bytes were allocated). Use b|k|m|g to specify the desired size unit

## mt.mem_used

Returns how many memory chunks and how many bytes are currently allocated via the mem_alloc module functions. Use b|k|m|g to specify the desired size unit.

## mt.mem_rnd_alloc

Takes 4 parameters: min, max, total_size and an optional unit (b|k|m|g). It will allocate total_size memory, in pieces of random size between min .. max (inclusive).

## mt.mem_test_start

Takes 7 parameters: min, max, total_size, min_interval, max_interval, test_time and an optional size unit (b|k|m|g). All the time units are ms. It will run a memory allocation test for test_time ms. At a random interval between min_interval and max_interval ms. it will allocate a memory chunk with random size, between min and max. Each time total_size is reached, it will free all the memory allocated and start again. Returns the test id (integer)

## mt.mem_test_stop

Takes 1 parameter: the test id. It will stop the corresponding test. Note: the test is stopped, but not destroyed.

## mt.mem_test_destroy

Takes 1 parameter: the test id. It will destroy the corresponding test.

## mt.mem_test_destroy_all

It will destroy all the tests (running or stopped).

## mt.mem_test_list

If a test id parameter is provided it will list the corresponding test, else it will list all of them. Use b |k | m | g as a second parameter for the size units (default bytes)