-
Notifications
You must be signed in to change notification settings - Fork 831
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unwanted code size increase in v2.7.0 because of String constants #989
Comments
Bugger! That behaviour didn't show up in my testing. My testing had the overall size go down albeit for code that was using said strings etc.
Please! I'd really like to avoid c-style string handling as the memory allocation/handling is a nightmare. I tried putting the strings in PROGMEM, but everything blew up. Any guidance you've got for successfully doing that is more than welcome.
Reducing the duplication of string literals was actually smaller. A 1.5k reduction in the binary size. I was surprised myself. No argument that storing the strings as Again, I'm open to all suggestions to reduce the overhead. How does Tasmota handle the string concatenation memory allocation issues etc? Also, do you have a link to your analysis notes at all? I'm interested in your findings and how to replicate them. i.e. Teach me! :) |
* Use PROGMEM for c_str's as well. * Reduces flash binary size. o IRrecvDumpV2: ~1kb saved. o IRMQTTServer: ~2.7kb saved. Testing: * Passes existing all unit tests. * IRrecvDumpV2: Run on a NodeMCU board. Decodes Kelvinator A/C remote as before. * IRMQTTServer: Run on a NodeMCU board. Web interface checked. Didn't crash. For #989 FYI @s-hadinger
@s-hadinger Can you please download and checkout the #992 / https://github.com/crankyoldgit/IRremoteESP8266/tree/strings branch and let me know how it performs memory-wise with Tasmota etc. |
Thanks, will do now. |
Good news. For the minimal IR support in Tasmota standard, there is no change compared to the patched IRtext.cpp. The unwanted code flash increase is gone. For the version of Tasmota with full IR support, I do see a Flash/Ram size reduction: v2.7.0: strings branch: |
Excellent. I'll merge and close this issue. Thanks for confirming. |
* Use `char*` instead of `String` for common text. * Use PROGMEM for c_str's as well. * Reduces flash binary size. o IRrecvDumpV2: ~1kb saved. o IRMQTTServer: ~2.7kb saved. Testing: * Passes existing all unit tests. * IRrecvDumpV2: Run on a NodeMCU board. Decodes Kelvinator A/C remote as before. * IRMQTTServer: Run on a NodeMCU board. Web interface checked. Didn't crash. Fixes #989
_v2.7.1 (20191125)_ **[Bug Fixes]** - Hitachi424Ac: Fix Incorrect Power Byte Values (#987) - Coolix: Fix setPower(false) issue. (#990) **[Features]** - Use `char*` instead of `String` for common text. Saves ~1-3k. (#992, #989) - Hitachi424Ac: Add Vertical Swing ability (#986) **[Misc]** - IRMQTTServer: Update HA example/discovery message. (#995) - Move newly added common text to a better location. (#993)
_v2.7.1 (20191125)_ **[Bug Fixes]** - Hitachi424Ac: Fix Incorrect Power Byte Values (#987) - Coolix: Fix setPower(false) issue. (#990) **[Features]** - Use `char*` instead of `String` for common text. Saves ~1-3k. (#992, #989) - Hitachi424Ac: Add Vertical Swing ability (#986) **[Misc]** - IRMQTTServer: Update HA example/discovery message. (#995) - Move newly added common text to a better location. (#993)
FYI, this has been included in the just released version 2.7.1 of the library. |
Thanks David. I will update Tasmota. |
Hi David, great lib!
When upgrading Tasmota with IRremoteESP8266 v2.7.0, we saw a code increase of 3.8KB in Flash size.
Digging into it, the code increase came from
IRtext.cpp
creating a log ofString
objects that were actually not used in the Tasmota build. A quick fix disables the Strings when we are compiling standard Tasmota.https://github.com/arendst/Tasmota/blob/development/lib/IRremoteESP8266-2.7.0/src/IRtext.cpp
I would advise against using
String
for constants because of the following:String
objects cannot be removed by the linker even if they are not used elsewhere in the code.String
objects reallocate the same strings in their own memory structures, meaning at least an additional 1.5KB of RAM spent.Actually it would be probably more compact to just use
char*
literals instead ofString
objects.Happy to discuss about alternatives.
Version/revision of the library used
v2.7.0 in Tasmota
The text was updated successfully, but these errors were encountered: