newlib-nano heap requirements

Asked by florian

This is a follow-up question to https://answers.launchpad.net/gcc-arm-embedded/+question/233446

It is stated there printf with newlib-nano requires a "tiny" initial malloc to setup libc structures.

Seeing this I expected, on my cortex-m3 system, to end up with tens of bytes, maybe 100 at most, reserved.

I recently gave arm embedded (4.7 2013_q1 from linaro's website) with the newlib nano a try.
I followed these instructions to enable the nano profile : https://plus.google.com/102918008620512795495/posts/XUr9VBPFDn7

At runtime, placing a breakpoint on my _sbrk implementation shows that two allocations are initially made.

The first one is 436 Bytes big, while the second one is 1032 Bytes, so I end up with roughly 1.5K being allocated for one printf.
That's definitely not something I would have called tiny, so is this the expected size ?

Thank you,

Regards,

Florian

Question information

Language:
English Edit question
Status:
Solved
For:
GNU Arm Embedded Toolchain Edit question
Assignee:
No assignee Edit question
Solved by:
chengbin
Solved:
Last query:
Last reply:
Revision history for this message
Best chengbin (can-finner) said :
#1

Hi Florian V. ,
Thanks for reporting this to us. Going through the previous question, it seems that TM (tm1234) recommended another implementation of TINY printf which requires no heap consumption.

I agree with you that the heap consumption of newlib-nano with printf is some kind of big for tiny systems.
If I remember correctly, the first 400+ bytes comes from dynamically allocated FILE structure of streamio, the second 1000+ bytes comes from buffer of streamio. Though it's inevitable since we keeps streamio in newlib-nano, the heap consumption can be decreased with further changes like smaller buffer, etc.. We didn't do that so far because we want to keep code of newlib-nano in line with newlib as much as possible.

Simply speaking, the consumption is as expected for now, and this might be improved in the future.

Hoping this can help. Thanks very much.

Revision history for this message
florian (ey3ball) said :
#2

Hi chengbin,

I did see the part about the tiny printf implementation, I was just wondering what we could expect exactly from newlib-nano.

Thank you for clarifying this ,

Regards,

Florian

Revision history for this message
florian (ey3ball) said :
#3

Thanks chengbin, that solved my question.