Memory Manager Configuration#

Configuration Files#

sl_memory_manager_config.h#

Contains core Memory Manager configuration parameters:

// Minimum block allocation size (32-128 bytes, 8-byte increments)
#define SL_MEMORY_MANAGER_BLOCK_ALLOCATION_MIN_SIZE   (32)

// Enable/disable statistics API
#define SL_MEMORY_MANAGER_STATISTICS_API_ENABLE       1

Configuration Parameters:

Parameter

Range

Default

Description

SL_MEMORY_MANAGER_BLOCK_ALLOCATION_MIN_SIZE

32-128 bytes

32

Minimum size for allocated blocks. Larger values reduce fragmentation but increase memory overhead. Must be multiple of 8.

SL_MEMORY_MANAGER_STATISTICS_API_ENABLE

0 or 1

1

Enables heap statistics functions. Disable to save memory in constrained applications.

sl_memory_manager_region_config.h#

Contains memory region configuration:

// Application stack size configuration
#define SL_STACK_SIZE  // Defined by linker or user configuration

Configuration Examples#

Basic Configuration#

// Default configuration for most applications
#define SL_MEMORY_MANAGER_BLOCK_ALLOCATION_MIN_SIZE   (32)
#define SL_MEMORY_MANAGER_STATISTICS_API_ENABLE       1

Use Case: General-purpose applications with moderate memory requirements.

Memory-Constrained Configuration#

// Optimized for memory-constrained applications
#define SL_MEMORY_MANAGER_BLOCK_ALLOCATION_MIN_SIZE   (32)
#define SL_MEMORY_MANAGER_STATISTICS_API_ENABLE       0  // Disable to save memory

Use Case: Applications with very limited memory where every byte counts.

Alignment Constants#

You can choose one of these pre-defined alignments for your block allocation request. The default alignment when using SL_MEMORY_BLOCK_ALIGN_DEFAULT is 8 bytes. This constant can be passed as a parameter to the function sl_memory_alloc_advanced().

// Pre-defined alignment values
#define SL_MEMORY_BLOCK_ALIGN_DEFAULT     0xFFFFFFFFU  // Default alignment
#define SL_MEMORY_BLOCK_ALIGN_8_BYTES     8U           // 8 bytes alignment
#define SL_MEMORY_BLOCK_ALIGN_16_BYTES    16U          // 16 bytes alignment
#define SL_MEMORY_BLOCK_ALIGN_32_BYTES    32U          // 32 bytes alignment
#define SL_MEMORY_BLOCK_ALIGN_64_BYTES    64U          // 64 bytes alignment
#define SL_MEMORY_BLOCK_ALIGN_128_BYTES   128U         // 128 bytes alignment
#define SL_MEMORY_BLOCK_ALIGN_256_BYTES   256U         // 256 bytes alignment
#define SL_MEMORY_BLOCK_ALIGN_512_BYTES   512U         // 512 bytes alignment