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

WoonFoong WoonFoong at hotmail.com
Fri Jul 30 00:24:20 CEST 2004


but from what i test, i found that it did increase the rom size when i use


static prog_char data1[] = "prog_char file%dname[] = \" %s\";\n\n";
fprintf_P(fpout, data1, entryno, fsname);
(maybe is strcat_P or strcpy_P command)

it really add a few byte more to the rom, anyidea what happenning?

anyway i my program approach to 1axx x i nearly finish the ROM on my
coding:p
any example on how to save more rom on the programming method ?
Actually i already put nearly all the string to prog_char,
but add a lot function to let the program look clean and simple,
(by function calling function with a 2-4 layer deep)
around 20-30 function been create on my application.

i lost around 2-4K of heap size after i build my application.



Wf

----- Original Message ----- 
From: "Harald Kipp" <harald.kipp at egnite.de>
To: "Ethernut User Chat (English)" <en-nut-discussion at egnite.de>
Sent: Thursday, July 29, 2004 6:51 PM
Subject: Re: [En-Nut-Discussion] Ram Decrease when Program grow


> 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
>
> _______________________________________________
> En-Nut-Discussion mailing list
> En-Nut-Discussion at egnite.de
> http://www.egnite.de/mailman/listinfo.cgi/en-nut-discussion
>



More information about the En-Nut-Discussion mailing list