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.
Mailing lists / fpc-pascal / 2016-06
What is the best memory optimization parameter
3 messages · 2 people · –
- Cczd 2
- JJeppe Johansen 1
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
czd wrote 5 lines
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
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.
