# RPC Commands

## `mt.mem_alloc size [unit]`

Allocates the specified number of bytes. `unit` is optional and can be one of:

- b - bytes

- k - KB

- m - MB

- g - GB

### `mt.mem_alloc` usage

     $ &kamctl; rpc mt.mem_alloc 10 k

## `mt.mem_free [size] [unit]`

Frees at least `size` bytes from the memory allocated by other misctest functions (e.g. mt.mem_alloc).

`size` is optional. If missing, everything will be freed.

`unit` is optional and can be one of:

- b - bytes

- k - KB

- m - MB

- g - GB

### `mt.mem_free` usage

     $ &kamctl; rpc mt.mem_free 1 m

## `mt.mem_used [unit]`

Returns/displays how many bytes are allocated. The default unit is bytes (for all the possible units see above).

`unit` is optional and can be one of:

- b - bytes

- k - KB

- m - MB

- g - GB

### `mt.mem_used` usage

     $ &kamctl; rpc mt.mem_used
    9221460

## `mt.mem_rnd_alloc min max total [unit]`

Allocates `total_size` memory, in pieces of random size between `min` .. `max` (inclusive). `unit` is optional and represents the unit for all the given sizes (see above).

### `mt.mem_rnd_alloc` usage

     $ &kamctl; rpc mt.mem_rnd_alloc 1 64 10240 k

## `mt.mem_test_start min max total min_int max_int total_time [unit]`

Starts a malloc test that will take `total_time` to execute. Memory allocations will be performed at intervals randomly chosen between `min_int` and `max_int` (in ms). Each allocation will have a randomly chosen size between `min` and `max` `unit` bytes. After `total` `unit` bytes are allocated, everything is released/freed again and the allocations are restarted. All the times are expressed in milliseconds. `unit` is optional and represents the unit for all the given sizes (see above).

Several tests can be run in parallel.

Returns the test id.

### `mt.mem_test_start` usage

     $ &kamctl; rpc mt.mem_test_start 15 64 25000 128 1500 3600000 k
    1

## `mt.mem_test_stop id`

Stops the test identified by `id`.

### `mt.mem_test_stop` usage

     $ &kamctl; rpc mt.mem_test_stop 1

## `mt.mem_test_destroy id`

Destroys the test identified by `id` (besides stopping it, it also frees all the data, including the statistics).

### `mt.mem_test_destroy` usage

     $ &sercmd; mt.mem_test_destroy 1

## `mt.mem_test_destroy_all id`

Destroys all the running or stopped tests.

### `mt.mem_test_destroy_all` usage

     $ &sercmd; mt.mem_test_destroy_all

## `mt.mem_test_list [id] [unit]`

Returns/displays data about the test identified by `id`, or if no `id` is specified, it lists all the tests (running or stopped).

`unit` is optional. The default is is bytes (for all the possible units see above).

### `mt.mem_test_list` usage

     $ &sercmd; mt.mem_test_list
    {
    	ID           : 2
    	run time (s) : 1471
    	remaining (s): 2128
    	allocations  : 1749
    	errors       : 24
    	overflows    : 2
    	total alloc  : 69614530
    	min          : 15360
    	max          : 65536
    	total        : 25600000
    }
    {
    	ID           : 1
    	run time (s) : 3600
    	remaining (s): 0
    	allocations  : 4268
    	errors       : 640
    	overflows    : 4
    	total alloc  : 144220713
    	min          : 15360
    	max          : 65536
    	total        : 29696000
    }

## `mt.lock_test [executions]`

The mt.lock_test RPC command performs a lock/unlock stress test using a global lock. It is primarily intended for debugging and performance testing of the locking subsystem.

Usage:

            kamctl rpc mt.lock_test [executions]

- executions (integer): Number of times to lock and unlock.

If the argument is provided, it must be a positive integer. If if the argument is not a positive integer, the command will return an error.

Example:

            kamctl rpc mt.lock_test 10000

This will perform 10,000 lock/unlock operations.