# Functions

## `mt_mem_alloc(size)`

Allocates size bytes.

This is a debugging function for simulating memory leaks or stressing the memory allocator. It should not be used in production setups

### `men_alloc` usage

    ...
    mem_alloc(1048576); # 1MB
    ...

## `mt_mem_free()`

Frees all the memory allocated with mem_alloc() up to this point.

This is a debugging function for simulating memory leaks or stressing the memory allocator. It should not be used in production setups

### `mem_free` usage

    ...
    mem_free();
    ...

## `mt_tcp_thread_exec(text)`

Print the text via the tcp main process threads.

This is a debugging function for simulating execution on tcp main process threads. It should not be used in production setups

### `mt_tcp_thread_exec` usage

    ...
    mt_tcp_thread_exec("request $rm uri $ru");
    ...

## `mt_lock_test(count)`

Lock and unlock the global lock count times.

This is a debugging function for simulating locking and unlocking of global lock. It should not be used in production setups

### `mt_lock_test` usage

    ...
    mt_lock_test(100000000);
    ...

## `mt_lock_threads(nrthreads)`

Creates a set of threads that try to use the internal lock (see also lock_threads_mode parameter).

This is a debugging function to do locking and unlocking of an internal global lock from threads. It should not be used in production setups.

### `mt_lock_threads` usage

    ...
    mt_lock_threads("4");
    ...

## `mt_unlock_threads(nrops)`

Unlock the internal global lock used by mt_lock_threads(). It is done nrops-times.

This is a debugging function to do locking and unlocking of an internal global lock from threads. It should not be used in production setups.

### `mt_lock_threads` usage

    ...
    mt_unlock_threads("4");
    ...