[En-Nut-Discussion] Ram Decrease when Program grow

Harald Kipp harald.kipp at egnite.de
Thu Jul 29 19:51:26 CEST 2004


Hi,

At 12:11 29.07.2004 +0100, you wrote:
>I am working on Ram extensive application, i found that Nut OS was writing 
>in a very standard programming that we done on PC.
>my point was below.
>some part of OS lib was write on example like this
>  fprintf(fpout, "prog_char file%dname[] = \"%s\";\n\n", entryno, fsname);
>if let say we put it to
>
>static prog_char data1[] = "prog_char file%dname[] = \"%s\";\n\n";
>fprintf_P(fpout, data1, entryno, fsname);
>we will able to free 3xByte of Ram from Heap Memory, But the Rom Size Will 
>grow 8-16Byte

This will save you 'sizeof(data1)' bytes of RAM. Actually it
will not save heap memory, but reduce variable space (data
segment). Because the heap will occupy all remaining RAM, it
will finally give you more heap space.

Heap is a bit different, because there's some overhead.
malloc(1) will occupy 16 bytes, if I remember correctly.
Not only because of management overhead, but also because
of a fragmentation reducing threshold.

It will not add any ROM, because the string will be in
ROM anyway. But using prog_char instead of char will avoid,
that the string is copied to RAM during initialization.

Further information is available at
http://www.nongnu.org/avr-libc/user-manual/index.html



>
>i am not sure how you guys think.
>Any Expert recomment we save more Rom or Ram on the NutOS
>Ram maybe more easy expandable by adding external Ram(like use Ethernut2)
>or we save limited Ram size by putting all the String to Prog_char ?

RAM is limited to 64k minus memory mapped I/O space. Ethernut 2
banked RAM is not natively available to the compiler.

It's always a good idea to have a look to the compiler's map file
and check, where all this RAM and ROM is used. Also check the
compile options, but typically -Os provides the most compact code.

Looking to TCP over PPP with several thousand lines of code, which
still fits into around 32 kByte ROM, I'm wondering what kind of
application will run out of ROM?

Harald




More information about the En-Nut-Discussion mailing list