Getting Free Memory

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Getting Free Memory

跳至解决方案
1,010 次查看
rdazcal
Contributor III

Greetings,

 

Is there a reason for MQX not having a function to let me know how much free RAM memory it has?

 

I can't use MQX CodeWarior plugins since mine is a Basic version.

 

I'm using "_mem_get_highwater()", but if I understood correctly (I looked into the source code), it gives me the address of the highest allocated memory (which helps a bit), but as far as I know, this allocated memory could consume the whole RAM...

 

I noticed in the source a "_mem_get_size()", but it does not seem to be implemented.

0 项奖励
1 解答
518 次查看
JuroV
NXP Employee
NXP Employee

There is one reason, why it is not implemented. Getting the size of free memory does not tell anything about if I can allocate some memory. Just for clarification, there can be 1 block of 1024 Bytes free or 128 blocks of 8 Bytes free spread over the whole heap, both situations return the same result of _mem_get_free.

There is another particular reason (which you can accept or nor) that when the call is not synchronized in multitask application by the user, he will not get right result (because immediatelly after evaluating a result, another task can allocate memory).

在原帖中查看解决方案

0 项奖励
1 回复
519 次查看
JuroV
NXP Employee
NXP Employee

There is one reason, why it is not implemented. Getting the size of free memory does not tell anything about if I can allocate some memory. Just for clarification, there can be 1 block of 1024 Bytes free or 128 blocks of 8 Bytes free spread over the whole heap, both situations return the same result of _mem_get_free.

There is another particular reason (which you can accept or nor) that when the call is not synchronized in multitask application by the user, he will not get right result (because immediatelly after evaluating a result, another task can allocate memory).

0 项奖励