Hi, I want to do a memory optimization of the Nano in combination with the ENC28J60. I only need the UDP communication.
Has anyone already performed such optimization or how could the solution look like? I suspect that a lot of routines are running in this library, which are not necessarily needed for my application.
That's the basic payload of my code. Of course, processing between the UDP messages is done. However, this is sufficient as an optimization starting point.
Modern compilers/linkers are quite good at removing unused code. Did you check if there are options to enable this and whether they are already used by the Arduino IDE?
The optimization settings will depend on which hardware core you are using (which depends on which board you are compiling for). Most of the Arduino cores are now using LTO, which further enhances the compiler's ability to optimize the code.
You should be aware that there is the original version of the UIPEthernet library:
which doesn't seem to be maintained anymore, and a fork:
Which has had some recent development work (though in a rather haphazard manner unfortunately). You might do a comparison of each of the library versions to see if there is a significant difference for your application.
Basically I was receiving UDP packets with large headers that i didnt need very much of so i made changes to enable me to skip to particular bytes in the packet without having to transfer the data over SPI to the arduino ... saving precious time and allowing me to move onto the next packet faster and not have to copy that into the arduino ram.
This was done some time ago so no idea how it relates to other versions but i suspect you could retrofit similar changes to a current version of the library if it was useful to you.