cancel
Showing results for 
Search instead for 
Did you mean: 

malloc library - _sbrk problem

Zainka
Associate III
Posted on September 02, 2012 at 00:47

I was trying to use malloc in a project  which has been ported from an other platform. I get the message that...

_sbrk

 ... is undefined. This is used by _sbrk_r which again is used by malloc. I found no solution herein but looked at the following at http://embdev.net/topic/129753   I am not very familiar to this so a little help would do. I can create the function if needed, no prob. but I find it likely that this has already been solved somehow for stm32fxx devices and i rather like the idea to have something dedicated instead for me trying to implement this myself.

FYI : The heap size is set to 16KB

Breg

Vidar

#malloc-_sbrk #dynamic-allocation---just-say-no
1 ACCEPTED SOLUTION

Accepted Solutions
Posted on September 02, 2012 at 02:44

Dynamic memory allocation in embedded systems is very problematic, basically revolving around memory leakage, heap fragmentation and what to do when the allocation fails.

Consider your options to statically allocate resources, or fixed pools.

http://en.wikipedia.org/wiki/Memory_management#Fixed-size-blocks_allocation

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

View solution in original post

2 REPLIES 2
Posted on September 02, 2012 at 02:44

Dynamic memory allocation in embedded systems is very problematic, basically revolving around memory leakage, heap fragmentation and what to do when the allocation fails.

Consider your options to statically allocate resources, or fixed pools.

http://en.wikipedia.org/wiki/Memory_management#Fixed-size-blocks_allocation

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on September 03, 2012 at 13:59

''I can create the function if needed, no prob. but I find it likely that this has already been solved somehow for stm32fxx devices...''

 

As clive1 suggests, the usual ''solution'' for embeded systems is to

not

   use dynamic memory allocation!

Your time may be better spent adjusting the code to a more ''embedded-friendly'' approach...