false

false

EN

sdk zi-data大小问题

774****com

2021-08-26 18:36:46

同一个程序在不同sdk情况下zi-data大小占用相差很大。

sdk-v1.6.08(Program Size: Code=93308 RO-data=7008 RW-data=1444 ZI-data=70148 )

sdk-v1.6.10(Program Size: Code=91360 RO-data=6272 RW-data=1380 ZI-data=90540 )

对比map文件后发现原因是app_memory.h文件下的参数设置不同:

sdk-v1.6.08:#define APP_MEM_HEAP_SIZE (12 * 1024) /**< Total app memory heap size. */

sdk-v1.6.10:#define APP_MEM_HEAP_SIZE (32 * 1024) /**< Total app memory heap size. */

如果我改回(12*1024)会有问题吗?

774****com

2021-08-26 18:48:06

这个参数用在了app_memory.c下

/* * LOCAL VARIABLE DEFINITIONS ***************************************************************************************** */

static __align(APP_MEM_ALIGN_NUM) uint8_t s_mem_heap[APP_MEM_HEAP_SIZE];

static app_mem_block_t s_start_list_node;static app_mem_block_t s_end_list_node;

static size_t s_curr_free_bytes;

static size_t s_ever_free_bytes_min;

/* * LOCAL FUNCTION DEFINITIONS ***************************************************************************************** */

static void app_mem_init(void)

 app_mem_block_t *p_fir_free_block; 

 s_start_list_node.p_next_free_block = (void *)s_mem_heap; 

 s_start_list_node.block_size = 0; 

 s_end_list_node.p_next_free_block = NULL; 

 s_end_list_node.block_size = 0; p_fir_free_block = (void *)s_mem_heap;

 p_fir_free_block->p_next_free_block = &s_end_list_node; 

 p_fir_free_block->block_size = APP_MEM_HEAP_SIZE; 

 s_curr_free_bytes = p_fir_free_block->block_size; 

 s_ever_free_bytes_min = p_fir_free_block->block_size;

}

0条评论

您的评论

774****com

2021-08-26 18:51:09

如果我把它改成:

/* * LOCAL VARIABLE DEFINITIONS ***************************************************************************************** */

//static __align(APP_MEM_ALIGN_NUM) uint8_t s_mem_heap[APP_MEM_HEAP_SIZE];

static app_mem_block_t s_start_list_node;

static app_mem_block_t s_end_list_node;

static size_t s_curr_free_bytes;

static size_t s_ever_free_bytes_min;

/* * LOCAL FUNCTION DEFINITIONS ***************************************************************************************** */

static void app_mem_init(void)

{

 __align(APP_MEM_ALIGN_NUM) uint8_t s_mem_heap[APP_MEM_HEAP_SIZE]; 

 app_mem_block_t *p_fir_free_block;

 s_start_list_node.p_next_free_block = (void *)s_mem_heap; 

 s_start_list_node.block_size = 0; 

 s_end_list_node.p_next_free_block = NULL; 

 s_end_list_node.block_size = 0; 

 p_fir_free_block = (void *)s_mem_heap;

 p_fir_free_block->p_next_free_block = &s_end_list_node; 

 p_fir_free_block->block_size = APP_MEM_HEAP_SIZE; 

 s_curr_free_bytes = p_fir_free_block->block_size; 

 s_ever_free_bytes_min = p_fir_free_block->block_size;

}

改成这个样子把它放到函数内部变成局部变量空间全省下来了,会不会有问题?

0条评论

您的评论

185***527

2021-08-27 13:56:39

你好

1.   APP_MEM_HEAP_SIZE含义是分配给内存池的大小,具体大小分配可根据使用应用场景而定;

2.   内存池是全局使用的,如果使用 s_mem_heap 定义为函数局部变量,则内存池指向主栈空间,会因内存互踩导致系统崩溃;

希望以上回答对你有帮助!                                                                           

0条评论

您的评论

共 3条记录
1

您的回答