52235 malloc problem

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

52235 malloc problem

Jump to solution
1,236 Views
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

Labels (1)
0 Kudos
Reply
1 Solution
672 Views
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

View solution in original post

0 Kudos
Reply
3 Replies
672 Views
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 Kudos
Reply
672 Views
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 Kudos
Reply
673 Views
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 Kudos
Reply