lv_mem.h

Typedefs

typedef void *lv_mem_pool_t

Functions

void lv_mem_init(void)

Initialize to use malloc/free/realloc etc

void lv_mem_deinit(void)

Drop all dynamically allocated memory and reset the memory pools' state

lv_mem_pool_t lv_mem_add_pool(void *mem, size_t bytes)
void lv_mem_remove_pool(lv_mem_pool_t pool)
void *lv_malloc(size_t size)

Allocate memory dynamically

Parameters:

size – requested size in bytes

Returns:

pointer to allocated uninitialized memory, or NULL on failure

void *lv_calloc(size_t num, size_t size)

Allocate a block of zeroed memory dynamically

Parameters:
  • num – requested number of element to be allocated.

  • size – requested size of each element in bytes.

Returns:

pointer to allocated zeroed memory, or NULL on failure

void *lv_zalloc(size_t size)

Allocate zeroed memory dynamically

Parameters:

size – requested size in bytes

Returns:

pointer to allocated zeroed memory, or NULL on failure

void *lv_malloc_zeroed(size_t size)

Allocate zeroed memory dynamically

Parameters:

size – requested size in bytes

Returns:

pointer to allocated zeroed memory, or NULL on failure

void lv_free(void *data)

Free an allocated data

Parameters:

data – pointer to an allocated memory

void *lv_realloc(void *data_p, size_t new_size)

Reallocate a memory with a new size. The old content will be kept.

Parameters:
  • data_p – pointer to an allocated memory. Its content will be copied to the new memory block and freed

  • new_size – the desired new size in byte

Returns:

pointer to the new memory, NULL on failure

void *lv_malloc_core(size_t size)

Used internally to execute a plain malloc operation

Parameters:

size – size in bytes to malloc

void lv_free_core(void *p)

Used internally to execute a plain free operation

Parameters:

p – memory address to free

void *lv_realloc_core(void *p, size_t new_size)

Used internally to execute a plain realloc operation

Parameters:
  • p – memory address to realloc

  • new_size – size in bytes to realloc

void lv_mem_monitor_core(lv_mem_monitor_t *mon_p)

Used internally by lv_mem_monitor() to gather LVGL heap state information.

Parameters:

mon_p – pointer to lv_mem_monitor_t object to be populated.

lv_result_t lv_mem_test_core(void)
lv_result_t lv_mem_test(void)

Tests the memory allocation system by allocating and freeing a block of memory.

Returns:

LV_RESULT_OK if the memory allocation system is working properly, or LV_RESULT_INVALID if there is an error.

void lv_mem_monitor(lv_mem_monitor_t *mon_p)

Give information about the work memory of dynamic allocation

Parameters:

mon_p – pointer to a lv_mem_monitor_t variable, the result of the analysis will be stored here

struct lv_mem_monitor_t
#include <lv_mem.h>

Heap information structure.

Public Members

size_t total_size

Total heap size

size_t free_cnt
size_t free_size

Size of available memory

size_t free_biggest_size
size_t used_cnt
size_t max_used

Max size of Heap memory used

uint8_t used_pct

Percentage used

uint8_t frag_pct

Amount of fragmentation