Hi! I’m making an LED lantern project using Arduino via PlatformIO / C++, built on an ATtiny84.
My core issue is that I’m running out of space on the MCU.
My main current issue is that, while trying to compress filesize, I’ve found that my int
s seem to be taking up WAY more than the 2 bytes they’re supposed to. Specifically, I’ve found one that seems to be taking up 208 bytes , which is… uh, more, than two. Even if there were some funky behind-the-scenes assignment of pointers and stuff, there’s NO way changing a single int to a byte should save this much space?
I’m concerned because, while I AM converting as many ints to bytes as I can, there are several I have to keep as ints for tracking larger values. Not to mention the libraries I’m using, where there’s probably many ints in use. If every int is taking up ~210 bytes, that’s a HUGE issue when I only have 8kB of flash.
Any idea what’s going on here? And, hopefully, how to prevent it?
Pics of the issue showing the code and terminal output below (imgur album). Note that the result seems the same whether I use static
or not, int8_t
/ int16_t
instead of byte
/ int
, whatever.
The project is open source, so if you want to look at the code in its entirety, here you go.
I’ve also made a post on Reddit about this issue, and there’s been some discussion there. No solutions or explanations yet, though
Thank you!
Showing the filesize using an int (7524 bytes)
Showing the filesize using a byte (7316 bytes, 208 fewer)
Showing the filesize using a byte (7316 bytes, 208 fewer)