52235 malloc problem

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

52235 malloc problem

跳至解决方案
1,714 次查看
Balcer
Contributor II

Since 5223x chips have small RAM I should expect it fills up some day. But not so quickly. My CW7.2 shows project's (depends on settings) code size from 5 to 8kB. Data size about 1.5kB. Now at runtime I allocate memory for few structures. After allocating about 800 bytes I get errno: 12 and no allocation at all. I thought I have 32 kB of RAM at hand... It's quite odd that setting different optimization I get from 5 to 8 kB of code but no difference in malloc behavior. What is going on? Any ideas? 

 

Running CW7.2SE, RAM configuration, EWL C.

 

 

TIA,

Michal

标签 (1)
0 项奖励
回复
1 解答
1,150 次查看
CompilerGuru
NXP Employee
NXP Employee

One issue was in the past (saw last mails years ago, I don't know about the 7.2 setup) that memory pools were used.

Search in old threads, for example

https://community.freescale.com/message/43154#43154

 

Another thing to check is how your lcf is setup, maybe you just do not allocate more RAM for the heap?


Daniel

在原帖中查看解决方案

0 项奖励
回复
3 回复数
1,150 次查看
Balcer
Contributor II

SOLVED!

I've changed ___heap_size   in the .lcf file to 0x800 and it helped.

 

Thanks a lot for quick response.

0 项奖励
回复
1,150 次查看
TomE
Specialist II

See if CW provides (or can be made to provide) a MAP file. Examine that to see how the memory is allocated.

 

Memory is usually taken up with (in order) the Interrupt Vectors, Code, Data, BSS, Heap and Stack.

 

The "heap" is what Malloc uses. It and the Stack usually share all the remaining memory. Somewhere in the project you have to tell CW how much to allocate for the Stack, with the remaining usually being for the Heap. If your Stack is too big (or somehow the project is set for no heap) then that might explain your problem.

 

0 项奖励
回复
1,151 次查看
CompilerGuru
NXP Employee
NXP Employee

One issue was in the past (saw last mails years ago, I don't know about the 7.2 setup) that memory pools were used.

Search in old threads, for example

https://community.freescale.com/message/43154#43154

 

Another thing to check is how your lcf is setup, maybe you just do not allocate more RAM for the heap?


Daniel

0 项奖励
回复