Visitar URL original
RAM usage and binary size have exploded on AVR in 3.9.17 · Issue #1930 · FastLED/FastLED · GitHub
Skip to content

RAM usage and binary size have exploded on AVR in 3.9.17 #1930

Closed

Description

@sutaburosu

With this release, I run out of RAM when trying to drive a single pixel on a Nano. Just #include'ing FastLED without using it burns over 1KiB of RAM. These results are from building with Arduino IDE 1.8.19.

/*     RAM used (bytes) to show() 1 LED vs FastLED version

|                  | (1) #include | (2) CRGB,addLeds<> | (3) CHSV, show() | Global vars (1/2/3)| Flash used (1/2/3)|
|------------------|--------------|--------------------|------------------|--------------------|-------------------|
| (0) No FastLED   | 206          |                    |                  | 192                | 1908              |
| FastLED 3.9.16   | 223 (+17)    | 306 (+83)          | 334 (+28)        | 209/292/320        | 1946/4314/5234    |
| FastLED 3.9.17   | 1338 (+1134) | ??? crash          | ??? crash        | 869/952/980        | 6424/8792/9712    |

Test sketch and full results.

Activity

  1. nomakewan commented on May 25, 2025

    @nomakewan
    Contributor

    Have confirmed this on our Mega 2560 project as well.

    Compiling with Arduino IDE 1.8.19:
    FastLED 3.9.16
    Sketch uses 92368 bytes (36%) of program storage space. Maximum is 253952 bytes.
    Global variables use 6041 bytes (73%) of dynamic memory, leaving 2151 bytes for local variables. Maximum is 8192 bytes.

    FastLED 3.9.17
    Sketch uses 96142 bytes (37%) of program storage space. Maximum is 253952 bytes.
    Global variables use 6695 bytes (81%) of dynamic memory, leaving 1497 bytes for local variables. Maximum is 8192 bytes.
    Low memory available, stability problems may occur.

    And with PIO:
    FastLED 3.9.16

    RAM:   [=======   ]  72.9% (used 5972 bytes from 8192 bytes)
    Flash: [====      ]  36.3% (used 92070 bytes from 253952 bytes)
    

    FastLED 3.9.17

    RAM:   [========  ]  80.9% (used 6626 bytes from 8192 bytes)
    Flash: [====      ]  37.7% (used 95816 bytes from 253952 bytes)
    
  2. sutaburosu commented on May 25, 2025

    @sutaburosu
    ContributorAuthor

    Have confirmed this on our Mega 2560 project as well.

    @nomakewan, thanks for confirming the increase in RAM usage and binary size. Did you try flashing the resulting binary to a device, and does it work? I can't get very simple sketches to display anything on just a single LED. As I mentioned in the release announcement on r/fastled, FastLED seems to get trapped in an infinite loop reallocating memory for a HashMap if FastLED.addLeds<> is present in the sketch.

  3. nomakewan commented on May 26, 2025

    @nomakewan
    Contributor

    Apologies for the delay in responding; I did not originally attempt flashing to the device. I have done so just now and likewise confirm that the device is dead and no LED actions occur. 3.9.17 appears to be a death sentence for AVR.

  4. sutaburosu commented on May 27, 2025

    @sutaburosu
    ContributorAuthor

    Thanks to a post on r/FastLED I've just learned that FastLED 3.9.17 only works with an odd number of LEDs. Any even number of LEDs causes it freeze during startup.

    If I add Serial.begin(2000000) then this swaps. Only even numbers of LEDs work, whilst odd numbers fail to start up correctly.

    This seems to indicate that memory alignment may be involved somehow.

  5. nomakewan commented on May 27, 2025

    @nomakewan
    Contributor

    Interesting; that does track with my findings. The device in question defaults to two pins, one with 64 LEDs and the other with 62 LEDs.

    Notably changing these so that they are odd does not reduce the massive bloat in program size and RAM, so even if it "works" with odd numbers of LEDs there is still clearly something far more fundamental gone wrong.

  6. zackees commented on May 28, 2025

    @zackees
    Member

    Is this problem only on nano or also uno?

  7. zackees commented on May 28, 2025

    @zackees
    Member

    Looks like a complex static object I used is being constructed unconditionally and not being tree-shooken out. Looks like this is why it's being emitted. I see it in wowki.

    I'm going to put the static inside a static function. That will defer initialization and also hopefully causes it to be removed by the linker since a function that is not called is side effect free.

  8. zackees commented on May 28, 2025

    @zackees
    Member

    Okay, looks like this might be an issue related to Arduino IDE. PlatformIO is not showing this regression. The whole month the UNO platform has the exact same build size:

    datetime,commit_hash,binary_size
    2025-05-19T21:23:50-07:00,6e40a782f8d32dbaaa66d8e02c855b73358d9892,10662
    2025-05-19T20:53:02-07:00,19ae075da2e8efb6735b7527636c6b65e2a04bef,10662
    2025-05-19T19:32:08-07:00,dc25e80e0e31b97f91d36df14bd24aabc964917c,10662
    2025-05-19T19:31:33-07:00,3aca40f16199ddca92e6ff9ce3738c0ff59d2afc,10662
    2025-05-19T20:28:47-06:00,fd4863f7576cb688bc60176e9f760f2b4c0414fb,10662
    2025-05-19T02:57:25-07:00,4d670929a3c3ab762e502542e729d28746e48ef0,10662
    2025-05-18T13:37:43-07:00,3cccccfd88b5b1602e777a64e8884cf2f2e9a5ec,10662
    2025-05-18T13:16:24-07:00,2953bfc1e6e0a53ac6dbd2846440cb7e8691be53,10662
    2025-05-17T17:21:48-07:00,eb6fb6855add1a7dd5eb7caa904cad45985c6d71,10662
    2025-05-16T14:58:07-07:00,11e03d5684af51f3acb6801f5f85be0e28ccbaba,10662
    2025-05-16T14:41:31-07:00,a58623539ae55cf2846294b5b0bbeca21ad9c4d3,10662
    2025-05-16T10:44:10-07:00,f3f6811350e9b78727bf110363500150c848dd3c,10662
    2025-05-16T00:40:32-07:00,124719160f30a6e69f22f931c5b5e3953228e9c9,10662
    2025-05-16T00:36:56-07:00,743ceeaa671bab48191946d988f14baaef9ee545,10662
    2025-05-16T00:24:56-07:00,219e0e9895d03120a96c004ad655e74553cff3d5,10662
    2025-05-15T13:08:54-07:00,77a786e2fd74757f3772d1471cdffcd2020dbc14,10662
    2025-05-15T01:38:01-07:00,a5c016551a623b47980aa0ded1ad40d464b54e25,10662
    2025-05-14T23:11:01-07:00,dd8b880acf8c82a36c9add57b607f3337ffb216e,10662
    2025-05-14T21:04:14-07:00,e6ae4586350c25afdb46f00670e7396867110315,10662
    2025-05-14T20:22:30-07:00,e2a7b045b690979eeb41b913ada38db29b5951b5,10662
    2025-05-14T13:34:05-07:00,4c3009d3eebb2f6a1a0a53efc7e4406ddd0cbbb2,10662
    2025-05-13T18:31:43-07:00,4491268a059363d8d43d06e2a5331c37d07235c8,10662
    2025-05-13T18:05:32-07:00,913be758e7687eb4c4d780225cd2ff1841879576,10662
    2025-05-13T17:23:19-07:00,0d3b23dcbc4f193075426d45de192c980fe1c232,10662
    2025-05-13T17:21:46-07:00,b17ea8b0c6dd7c688cadb1616b8221f3c7eb0a0f,10662
    2025-05-13T17:19:52-07:00,76c2b8fa4950bc568f3457ce0a5ba5497b5726dc,10662
    2025-05-13T17:17:58-07:00,28e4c1101c4c96f17eabf30b1ca0b7dc45046404,10662
    2025-05-13T17:14:45-07:00,3406a313a61ea9bd2420539969df6f796c035692,10662
    2025-05-13T17:12:52-07:00,0047605f30e33a76dcc0e314e351d46ca9c3c79b,10662
    2025-05-13T17:11:28-07:00,c476e55a4cc778f2c32a4d02ef475982d7b2fa6a,10662
    2025-05-13T17:06:39-07:00,8b613f6da3379cbbd031b983cd5d2274d196acd2,10662
    2025-05-13T15:22:40-07:00,0f52370246699e04370ef7dcab21a1dbd625d3c4,10662
    2025-05-13T14:45:23-07:00,f1dbf042ab1316e8782f25e3d665084de68bba50,10662
    2025-05-11T20:53:45-07:00,64d5183df01517e1519bbd738596ddf3b7f383e2,10662
    2025-05-11T20:40:32-07:00,b342e86ec2c11524cfb1c025ce221cc581fa942a,10662
    2025-05-11T20:26:52-07:00,4338e8f3bbc2983fda37bcf8223e81e25bf7c379,10662
    2025-05-11T20:26:40-07:00,517b40982157c83cf25be08dac5d7238b570686e,10662
    2025-05-11T16:27:05-07:00,4283016edcf75158b737ed66f1f68a63d5b34783,10662
    2025-05-11T15:33:29-07:00,6f7f6b696d554e45ce49082731f1025993c478ee,10662
    2025-05-11T15:30:00-07:00,d56a1480210f3da41034447f5e8d82299af2b7f0,10662
    2025-05-11T11:13:45-07:00,ecad31344e0712fa9e295574d5e3139b2dfac213,10662
    2025-05-11T05:48:37-07:00,a970cbccc99ceded80c97f2ea106495cb550e14e,10662
    2025-05-11T05:32:55-07:00,b2e7f280db1e9b1d5a968a0f98b291b34ea5ee30,10662
    2025-05-11T05:31:31-07:00,9bda2c71bcb1cb8da240d351459c1421bf4455ae,10662
    2025-05-11T05:24:59-07:00,255a0ca89def9faf63cb3c724a1c4b1d21db8774,10662
    2025-05-11T04:23:48-07:00,6c3aaf8336bf4c777d692536718c1c309286eca4,10662
    2025-05-11T02:21:27-07:00,15d7ed5a4b2fc13d818d3a3e9cd793272f3111d0,10662
    2025-05-11T02:14:49-07:00,de0998db3a424fd8049e8abb7726a47a6f4c3fc0,10662
    2025-05-11T01:57:21-07:00,5cc08fad404eb4a35615930c6dbe2803b35f1796,10662
    2025-05-11T01:36:19-07:00,f71c98132dcd6617c790a37a92f472dfc208f8b7,10662
    2025-05-11T01:19:37-07:00,8d708cb5803b184bc11a9805ff39c5df1410bf47,10662
    2025-05-11T00:29:27-07:00,1282a13d65d2115b6f26c92f0440f6d22b23013f,10662
    2025-05-11T00:25:00-07:00,a91636441a055043deca13432a9fb7b761a8483c,10662
    2025-05-10T23:40:36-07:00,8ecc1e863d3c611587268ad1e373b224cf9d6421,10662
    2025-05-10T22:21:32-07:00,5c6d616b6103c0adbe94332983951ea830c50aa6,10662
    2025-05-10T21:37:04-07:00,a371ad6ce29efee3c8ee62c0b968d0a4268b620f,10662
    2025-05-10T20:20:46-07:00,c73ca7f34b9cefa86e93e804be169a2420ede27b,10662
    2025-05-10T17:37:43-07:00,c68be9ac614fc8dec2da6927c0c88bc80dd2f5df,10662
    2025-05-10T17:06:24-07:00,022eea3749a2bcfd5a0d7fcb4596d72bdbd38654,10662
    2025-05-10T05:20:44-07:00,a3d21514b1d8e7b735ebb3549b820488ca0842e5,10662
    2025-05-10T05:19:35-07:00,f03fb5d6b37c4fd2e6260ffd738fd3ca4ace71c4,10662
    2025-05-10T03:57:17-07:00,9666cd9494ed63de128d7f08f21e435ef4aedfdc,10662
    2025-05-10T03:55:52-07:00,a098796059b39147d48e104a5c431eb2f625cd72,10662
    2025-05-10T03:29:25-07:00,0c25bbbc540754303b6058f363de87ec0d567c5b,10662
    2025-05-10T00:34:42-07:00,cfb24129bf553721fc8588e5d98a7a1b8e5e6761,10662
    2025-05-10T00:09:38-07:00,31ff134ece8adc5a8382f570b4bb6f0f07005cdc,10662
    2025-05-10T00:02:42-07:00,78b5192d01ce90780aba9dee4ff100b784e87d1f,10662
    2025-05-09T23:54:28-07:00,3e2775532336a304e7079f7161e2561ae79929c4,10662
    2025-05-09T23:34:05-07:00,689d31fce67c0868ab6fd48bbeee726f50c1b9eb,10662
    2025-05-09T23:28:55-07:00,b7aaf766f06c6108a90fb00a9b16e9ae8e7649b6,10662
    2025-05-09T23:25:48-07:00,3a6f812bca406dffc37f2893c6ff17996e55773b,10662
    2025-05-09T23:14:47-07:00,df6cd3dd9ed46c9215f1bd9dc1395f8ca89c8205,10662
    2025-05-09T22:56:35-07:00,b01317d17deec0303a4b9d90a2d846ef81b6f3a2,10662
    2025-05-09T22:43:16-07:00,ee409a503c81908c855b580e7792312eb26a3e90,10662
    2025-05-09T22:38:16-07:00,1089d24b1f76c69f02b9aae6e916484621377123,10662
    2025-05-09T22:21:24-07:00,161c3fbc7e5a3d43010f9c6aa1a165159be082b9,10662
    2025-05-09T22:05:58-07:00,003a571687ba432354ee6db7dc7618ec8cb46ba4,10662
    2025-05-09T22:04:43-07:00,557fbbd427999e16a8a4e7ce22cb74569e165f86,10662
    2025-05-09T21:32:34-07:00,4d182f585bb55c1dce1dc07678519b419b7ca8a8,10662
    2025-05-09T21:13:50-07:00,6b4daca62e0dc1aed394e6d210ee4a7fb274fe47,10662
    2025-05-09T20:23:50-07:00,4086058e0d40e29f590ec6c3af7771111cd6f118,10662
    2025-05-09T20:14:29-07:00,4a16de4466e216f2a3f2073404138812e0dd6a26,10662
    2025-05-09T20:07:55-07:00,61357daa46118c79f448792db8b9f010af5674a7,10662
    2025-05-09T19:17:13-07:00,c341750c00360a2369fc27ef3a32b9045c0d1901,10662
    2025-05-09T19:09:31-07:00,8250c9ca1b72a7648988efd326a50faaf47d220e,10662
    2025-05-09T19:08:12-07:00,dd12474421a6ee1ee8ff6b170be435e09b3e2de6,10662
    2025-05-09T19:04:30-07:00,81318744eb2b5fbd8123ac7f2d542dead62ad57a,10662
    2025-05-09T18:37:06-07:00,fb28c642f4e3b0c9708443491f73f1b2c8b83f5b,10662
    2025-05-09T18:25:38-07:00,b197c3c83a37c18481b2e8789995bc4c13f89116,10662
    2025-05-09T18:12:04-07:00,9bba44bfc5dcdaee8309cdb7b121ece9dcbbc8be,10662
    2025-05-09T18:09:56-07:00,7991c7e7f3b6c976f237b283762b0a75c03b6951,10662
    2025-05-09T18:07:12-07:00,744351df01be272c854bfe2561342b2a7de5a23e,10662
    2025-05-09T17:36:54-07:00,120476d69b1c918a6a2fc146128d58a0a47bb736,10662
    2025-05-09T17:15:15-07:00,5b8f3afe68e29467dcc54c45bf261b27f9d5747a,10662
    2025-05-09T17:02:05-07:00,5ab197a5ca39cd2ec63b6ff5f99291e4f647d315,10662
    2025-05-09T16:53:17-07:00,25797b0e3a8e6b612980b4e90debbfbbeb781147,10662
    2025-05-09T16:41:25-07:00,dc0b6bae71080ccd14467b44422e841bc39e8371,10662
    2025-05-09T16:36:40-07:00,d15bb6cbe8c2f42061156bc1f4ee11eeefee9fa9,10662
    2025-05-09T16:34:26-07:00,f7df3390d6e26c64c8bf2fbf20361c51c9464a0b,10662
    2025-05-09T16:25:38-07:00,745f40a2033963f26b3697ef8907b988a25851ab,10662
    2025-05-09T16:16:44-07:00,7252c086cee8d5eaab9db6714d106056ddec6529,10662
    2025-05-09T15:46:45-07:00,7c1bcfde14ebeda456d56a55682d972a6dc3262d,10662
    2025-05-09T15:36:26-07:00,395da0512a203a1e2657e88bca25be7da1f3d960,10662
    2025-05-09T15:29:28-07:00,2cfbd9dc762be95444a5cf13b859b3831f876372,10662
    2025-05-09T15:27:48-07:00,34d96178d3717e8f5e9cf22e8ed5906eb87e7679,10662
    2025-05-09T15:21:12-07:00,a324914972bb47dc0c55f6fba0d29cc075f5e9ff,10662
    2025-05-09T15:10:20-07:00,7f60dba86c343ceb336114cafc932dcb821fed21,10662
    2025-05-09T14:21:33-07:00,d95d263a72a0b395506bac4494375b7ff52e7ccb,10662
    2025-05-09T13:59:57-07:00,81a33247b83a6cc6a77a3ca5bc77bc9f5eadb6d5,10662
    2025-05-09T12:32:36-07:00,e2f9044f4cde75e5af065bcb7d94c0131bebc283,10662
    2025-05-09T12:29:26-07:00,38da4201fc6d480a124059e8592b74ea860f2985,10662
    2025-05-09T12:27:17-07:00,2669f97db9ce8f418936aca67fa88ebbeb65fda2,10662
    2025-05-09T12:24:57-07:00,b6aa7cedf8ef2471eabd2f4f3c2edc58f1bdf81d,10662
    2025-05-09T12:20:27-07:00,e6671c6d27c5666f9cfe14734c84b377d402a4a5,10662
    2025-05-09T12:19:20-07:00,8121c6b7ee65356c851b53fddc7dbb31121749d8,10662
    2025-05-09T10:38:55-07:00,0c14eeb75dc656145dccd6a4eb3e22236762120d,10662
    2025-05-09T10:36:06-07:00,18923e4e8200ef2ab0f5b414c3859f5fef15802d,10662
    2025-05-09T10:28:50-07:00,1dd495de854a522a15b874cab5d783ad91baaad2,10662
    2025-05-09T10:20:50-07:00,74845b8663698f060a61f85f14a0f4d332884ca9,10662
    2025-05-08T21:11:12-07:00,a632954d95a3116fe9ac4a19f5c981ddb2c94d72,10662
    2025-05-08T21:08:24-07:00,f1b2eef24a9bb27b21d291c4c3a7ef58ed67d203,10662
    2025-05-08T21:00:22-07:00,d033328526f09faffb7f0fa6030d4afef6a68d04,10662
    2025-05-08T19:30:38-07:00,85e75f5d12abff3ea5295353856a979a1afc1ee8,10662
    2025-05-08T18:46:55-07:00,981bc02dfb26c87dbfc9c30544067f1438e49fdb,10662
    2025-05-08T16:22:37-07:00,d5fec1c03af383238eb76e484a157fd96fb231a7,10662
    2025-05-08T15:05:45-07:00,b7d7639610afe93329907f37375a2135ff1f460c,10662
    2025-05-08T14:53:24-07:00,639a74ace3bdbe63555a2975ccb16e46d22b97a8,10662
    2025-05-08T14:52:57-07:00,1e8ba614950affbef794388205f33934744079b7,10662
    2025-05-08T14:42:59-07:00,748f02c0a8d869da73bcaec602e2705c5498bc31,10662
    2025-05-08T14:38:25-07:00,6d83231e5fb5bf2bdd165654cc989a31466b1852,10662
    2025-05-08T14:36:02-07:00,1efeefb8e0f36d57a2f2e90137695f650ca8c69a,10662
    2025-05-08T14:22:24-07:00,84d22ac4708240559e9c938e55af9a8564c75518,10662
    2025-05-08T13:39:50-07:00,951336047d61ed8d265d2cfd735a3954ba7d85ee,10662
    2025-05-08T11:27:38-07:00,328477fce4d5c28e34c6301b75bae8f840daac6c,10662
    2025-05-08T11:02:53-07:00,3d378fd64d3111b3b472755cee797e4fa896e666,10662
    2025-05-08T11:01:29-07:00,102eb8eb9a7c91f8e3041d0cf58d5989dc10051b,10662
    2025-05-08T10:57:58-07:00,a5be4932947dbc5a94239acf21d69f24dc1316fa,10662
    2025-05-08T10:49:20-07:00,b64551c02075ae0c7e9b15a8a5aef6dac1fdaf72,10662
    2025-05-08T10:19:26-07:00,86c1c1d854772e85bbcb965bb4ca4004f4f48a4b,10662
    2025-05-08T10:15:40-07:00,d8bbc9cca4c7204ae11a4af0f9c168543b109aa4,10662
    2025-05-08T10:10:15-07:00,58213537ef773bf23669df1db7b8956d8a43cda7,10662
    2025-05-08T09:26:53-07:00,29f0a935e7f149cb57221b42d59b691a35e4d87b,10662
    2025-05-08T08:21:42-07:00,c9159c6b6b314e31352aa3236abab546172870da,10662
    2025-05-08T08:19:45-07:00,219ec2b0f46876fdee96640bb43133cb0c8ec1d5,10662
    2025-05-08T08:16:55-07:00,152eda04a7fd0076e07bba5d0961fd7d78aae245,10662
    2025-05-08T08:03:57-07:00,b7ff45d990747934cd5fdc9f4b1c5015600baa94,10662
    2025-05-08T08:02:29-07:00,72c774f0cb90a5750e3597c7c8ea9b3497b407cf,10662
    2025-05-08T08:01:43-07:00,c2b5c2f273c89fab4cf59a0b5086e6f51cd082ac,10662
    2025-05-08T07:26:04-07:00,2de91b57f308de317feae9090e5262a9b8ca01b9,10662
  9. nomakewan commented on May 28, 2025

    @nomakewan
    Contributor

    Is this problem only on nano or also uno?

    Nano and Mega 2560 are affected so I must assume Uno is also affected.

    Okay, looks like this might be an issue related to Arduino IDE. PlatformIO is not showing this regression. The whole month the UNO platform has the exact same build size:

    Zack, we use PIO exclusively in our project and, as I posted above, you can see that the binary size and especially RAM usage have exploded on our Mega 2560 builds built with PIO. Further, the issue where the AVR is totally dead after flashing the binary compiled with PIO is still there.

    This is not an issue with the Arduino IDE.

    EDIT: Also the log you posted only goes back to 5/19, and 3.9.17 was released on the 24th. Possible that whatever introduced this behavior was done in those 5 days?

    EDIT EDIT: Here is our PIO INI for your reference:

    [platformio]
    build_cache_dir = .pio/buildcache ; Cache components after compilation to speed up next compile
    
    [env:megaatmega2560]
    platform = atmelavr
    board = megaatmega2560
    framework = arduino
    lib_deps =
        fastled/FastLED@^3.9.17 ; https://github.com/FastLED/FastLED
        powerbroker2/SafeString@^4.1.40 ; https://github.com/PowerBroker2/SafeString
        arduinogetstarted/ezButton@^1.0.6 ; https://github.com/ArduinoGetStarted/button
        powerbroker2/SerialTransfer@^3.1.4 ; https://github.com/PowerBroker2/SerialTransfer
        gpstar81/GPStar Audio Serial Library@^1.3.0 ; https://github.com/gpstar81/GPStarAudio-Serial-Library
        arminjo/digitalWriteFast@^1.3.0 ; https://github.com/ArminJo/digitalWriteFast
        avandalen/Switch@^1.2.8 ; https://github.com/avdwebLibraries/avdweb_Switch
        flav1972/ArduinoINA219@^1.1.1 ; https://github.com/flav1972/ArduinoINA219
        siteswapjuggler/Ramp@^0.6.3 ; https://github.com/siteswapjuggler/RAMP
        bakercp/CRC32@^2.0.0 ; https://github.com/bakercp/CRC32
    monitor_speed = 9600
    monitor_filters =
        time     ; Add timestamp with milliseconds for each new line
        default  ; Remove typical terminal control codes from input
        log2file ; Log data to a file “platformio-device-monitor-*.log” located in the current working directory
    upload_speed = 115200
    upload_port = /dev/cu.usbserial-A*
    
  10. zackees commented on May 28, 2025

    @zackees
    Member

    EDIT: Also the log you posted only goes back to 5/19, and 3.9.17 was released on the 24th. Possible that whatever introduced this behavior was done in those 5 days?

    It got truncated because my script aborted whenever one of the builds didn't work, I fixed it and re-ran from the last commit that was good. But otherwise its all the same number.

  11. zackees commented on May 28, 2025

    @zackees
    Member

    I submitted a fix already. If you want to run it again and see if it's fixed. I'll begin taking your platformio.ini file and try to reproduce.

  12. nomakewan commented on May 28, 2025

    @nomakewan
    Contributor

    I submitted a fix already. If you want to run it again and see if it's fixed. I'll begin taking your platformio.ini file and try to reproduce.

    Tested dfa2b8c against our project using the Arduino IDE. Here were the size results:

    Sketch uses 96142 bytes (37%) of program storage space. Maximum is 253952 bytes.
    Global variables use 6695 bytes (81%) of dynamic memory, leaving 1497 bytes for local variables. Maximum is 8192 bytes.
    Low memory available, stability problems may occur.
    

    This appears to be unchanged from 3.9.17. Is the fix in a separate branch from main?

  13. zackees commented on May 28, 2025

    @zackees
    Member

    Can you help me understand why you are compiling a complex project defined by a platformio.ini file through the arduino IDE?

    Do you have a parallel process where you install each of these dependencies through the Arduino IDE?

  14. zackees commented on May 28, 2025

    @zackees
    Member

    I submitted a fix already. If you want to run it again and see if it's fixed. I'll begin taking your platformio.ini file and try to reproduce.

    Tested dfa2b8c against our project using the Arduino IDE. Here were the size results:

    Sketch uses 96142 bytes (37%) of program storage space. Maximum is 253952 bytes.
    Global variables use 6695 bytes (81%) of dynamic memory, leaving 1497 bytes for local variables. Maximum is 8192 bytes.
    Low memory available, stability problems may occur.
    

    This appears to be unchanged from 3.9.17. Is the fix in a separate branch from main?

    Oops I forgot to check it in, here's the patch:

    9696074

  15. nomakewan commented on May 28, 2025

    @nomakewan
    Contributor

    Can you help me understand why you are compiling a complex project defined by a platformio.ini file through the arduino IDE?

    Do you have a parallel process where you install each of these dependencies through the Arduino IDE?

    Nope, just it's easier for me to pick-and-place the FastLED library with the IDE, so I copy the working directory somewhere else, copy the contents of includes into src, and then rename main.cpp to src.ino et voila, it opens in the Arduino IDE. I had in fact already done this several days ago so it was already sitting in that working directory ready for me to test with.

    If you would prefer I learn how to point the platformio.ini file towards a specific commit on a git repo I will, but I figured it was better to go with what I'm familiar with to offer a more immediate answer to your question.

    Oops I forgot to check it in, here's the patch:

    Tested against 9696074 and the result:

    Sketch uses 94944 bytes (37%) of program storage space. Maximum is 253952 bytes.
    Global variables use 6048 bytes (73%) of dynamic memory, leaving 2144 bytes for local variables. Maximum is 8192 bytes.
    

    This is still larger than 3.9.16 (by 4576 bytes of flash and 7 bytes of RAM) but not incredibly so. Unfortunately the issue where the board never makes it out of setup() is still present. No serial data comms, nothing. Still dead as a doornail.

  16. 24 remaining items

  17. nomakewan commented on May 28, 2025

    @nomakewan
    Contributor

    That commit does solve the odd/even LED issue.

    As for the resource use:

    RAM:   [=======   ]  73.0% (used 5979 bytes from 8192 bytes)
    Flash: [====      ]  37.3% (used 94658 bytes from 253952 bytes)
    

    For reference, 3.9.16:

    RAM:   [=======   ]  72.9% (used 5972 bytes from 8192 bytes)
    Flash: [====      ]  36.3% (used 92070 bytes from 253952 bytes)
    

    It's certainly more than 3.9.16 but nowhere near the massive jump from 3.9.17.

  18. zackees commented on May 28, 2025

    @zackees
    Member

    Thanks for your help! I going to merge in this change now and release.

  19. sutaburosu commented on May 28, 2025

    @sutaburosu
    ContributorAuthor

    Your efforts are greatly appreciated, Zach.

    My test sketch gives these results:

                   | (1) #include | (2) CRGB,addLeds| (3) CHSV, show| Globals (1/2/3)| Flash used (1/2/3)
    FastLED 3.9.16 | 223 (+17)    | 306 (+83)       | 334 (+28)     | 209/292/320    | 1946/4314/5234
    FastLED 3.9.17 | 1338 (+1134) | 1421 (+83)      | 1449 (+28)    | 869/952/980    | 6424/8792/9712
    FastLED 3.9.18 | ? hangs      | 766 (+??)       | 794 (+28)     | 222/305/333    | 5168/7536/8456
    

    The binary size is reduced, but still >3KiB larger than 3.9.16.

    Global vars are down to only 13 bytes more than 3.9.16. Runtime RAM usage is now 460 bytes more than 3.9.16, down from 1,115 more in 3.9.17.

    The odd/even problem is still present, although it is now reversed. Increasing CRGB leds[1]; to 2 causes the sketch to get stuck at boot.

  20. nomakewan commented on May 28, 2025

    @nomakewan
    Contributor

    Shit, confirmed. I just switched the LED count in my project to an odd number and sure enough, it stops working if I have an odd total now rather than even on 3.9.18. That's on me, when it started working again I should have switched the LED count to make sure that it wasn't just because the problem had flipped to being the opposite issue.

    I went back and found the last commit that worked properly in both odd and even configurations. That commit is 8a55629. Here was the resource report of that commit:

    RAM:   [=======   ]  72.9% (used 5972 bytes from 8192 bytes)
    Flash: [====      ]  36.3% (used 92094 bytes from 253952 bytes)
    

    The very next commit, commit 595e279, completely breaks once there is an odd number of total LEDs. It also caused a sudden jump in resources which was a telltale of the issue:

    RAM:   [========  ]  75.4% (used 6180 bytes from 8192 bytes)
    Flash: [====      ]  36.9% (used 93816 bytes from 253952 bytes)
    

    Again, my apologies for not switching up the LEDs to make sure the problem hadn't just flipped to the opposite issue.

  21. sutaburosu commented on May 28, 2025

    @sutaburosu
    ContributorAuthor

    I just ran git bisect from bc2a1d8 -> HEAD. I built each revision twice with odd/even number of LEDs in the Arduino IDE. I uploaded both the HEXes to Wokwi to see the results. That also landed on 595e279 as the first bad commit.

  22. zackees commented on May 28, 2025

    @zackees
    Member

    Gcc can't remove unused static global variables for some reason. Good catch!

  23. zackees commented on May 28, 2025

    @zackees
    Member

    Round 2

  24. sutaburosu commented on May 28, 2025

    @sutaburosu
    ContributorAuthor

    I don't pretend to fully understand the problem, but searching gives the impression that anonymous namespaces are the modern alternative to static globals. Perhaps even the ancient GCC 7.3.0 understands them and might do the right thing in this case?

  25. zackees commented on May 28, 2025

    @zackees
    Member

    I think the issue is that modern gcc removes globals if they think no one is linking to them.

    If the constructor is meant to invoke the desired side effect, then the result is that the constructor doesn't get run. This is surprising until the first time you experience it and to get around it you add a gcc attribute.

    It's not a good compiler feature and i believe it's theoretically wrong. However, I'm sure they get so much code removal because of it that they keep it in anyway and force people to mark the constructors as keep alive.

    But the older compiler's i don't think did this, and I think that's what we are having happen now. Older gcc keeps the constructors, new gcc/clang elides them.

    The fix is easy, just stick the global as a static variable inside a static function. Static constructors inside a function don't get run until the first call. And if no one links to that function, it can be removed.

  26. zackees commented on May 28, 2025

    @zackees
    Member

    Does this commit solve your even odd issue?

    https://github.com/FastLED/FastLED#0f9da866a6e096347f3a454d1a375d062fb88acd

  27. sutaburosu commented on May 28, 2025

    @sutaburosu
    ContributorAuthor

    Yes, yes it does! It also brings down the runtime memory usage to the same as 3.9.16.

    The binary size is also basically the same as 3.9.16, with just a couple of extra bytes used when only #include'ing, but gained back when actually using FastLED.

    Awesome. Thanks, Zach!

    FastLED 3.9.16 | 223 (+17)    | 306 (+83)       | 334 (+28)     | 209/292/320    | 1946/4314/5234
    FastLED 3.9.17 | 1338 (+1134) | 1421 (+83)      | 1449 (+28)    | 869/952/980    | 6424/8792/9712
    FastLED 3.9.18 | ? hangs      | 766 (+??)       | 794 (+28)     | 222/305/333    | 5168/7536/8456
    FastLED 0f9da86| 223 (+17)    | 306 (+83)       | 334 (+28)     | 209/292/320    | 1948/4314/5234
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions