malloc library - _sbrk problem
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2012-09-01 3:47 PM
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-noSolved! Go to Solution.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2012-09-01 5:44 PM
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
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2012-09-01 5:44 PM
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
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2012-09-03 4:59 AM
''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...A complex system designed from scratch never works and cannot be patched up to make it work.
