What is the best memory optimization parameter

classic Classic list List threaded Threaded
3 messages Options
czd
Reply | Threaded
Open this post in threaded view
|

What is the best memory optimization parameter

czd
Hi all,
What is the extreme memory optimization parameter to compile fpc for the embedded system? And could someone tell me what is the minimum memory specification for freepascal to run?
Thanks.
Reply | Threaded
Open this post in threaded view
|

Re: What is the best memory optimization parameter

Jeppe Johansen-3
On 06/15/2016 06:04 PM, czd wrote:
> Hi all,
> What is the extreme memory optimization parameter to compile fpc for the
> embedded system? And could someone tell me what is the minimum memory
> specification for freepascal to run?
> Thanks.
Depends on your platform really but usually the short answer is: all of
them :)

On the most extreme end of the scale there has been a proof of concept
RTL built for an AVR ATTiny28 which does not have any RAM at all, except
for 8 levels of hardware call stack. FPC could compile for that with
some careful hacking.

But usually on an embedded ARM core you would usually see an idle memory
usage of around 32-80 bytes of RAM for the RTL depending on how advanced
features you need. Heap manager requires a lot more of course,
initialization tables a little bit, soft fpu also a tiny bit, etc.

On ARM Cortex-M cores I usually compile with -O4 -Oonostackframe -XX.
That's pretty much all that is needed. Disabling the nostackframe
optimization is required for those specific cpu types due to a yet to be
fixed bug.

The only important trick is to always end your main program routine with
a "while true do;". This (usually) cuts out the finalization code saving
quite a bit of RAM and Flash.
And of course do not use exceptions or ansistrings/managed types in general.

Best Regards,
Jeppe
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
czd
Reply | Threaded
Open this post in threaded view
|

Re: What is the best memory optimization parameter

czd
Actually, I want to reduce the size of the fpc for linux/mips, I have tested the size of the ppcmips without the OPT,
OPT='-CX -Xs -XX' and OPT='-O4 -Oonostackframe -XX' options but nothings changed dramatically. All the OPT sizes are the same.
Is there something to forget?
Thanks.