Where does PROGMEM stuff go?
back in work arduino, learnt supposed put hardcoded strings progmem. great - fill sketches , logfiles lots of useful messages.
i've hit problems working sketch , have been led believe may down using progmem, or compilier writing wrong place. (something 64k limit?
- not sure of details). anyway, result decided try prune of cr4p i'd left lying in file keep progmem stuff in.
before started purging, when compiled project got following (on mega 2560 compiled on version 1.0).....
i removed of redundant progmem statements precompiler directive....
when compile
so i've saved myself massive 6 bytes!
is because compiler can't add up? or check if strings used in project anywhere before attempting allocate space? (all strings in above example stopped using ages ago, lazy remove @ time)
at moment have single file put progmem declarations in, , include 1 file in of projects. save compile space in largest project thinking of removing irrelevant stuff, if compiler checking if each string used, guess isn't going make difference?
cheers
i've hit problems working sketch , have been led believe may down using progmem, or compilier writing wrong place. (something 64k limit?
![huh? ???](https://forum.arduino.cc/smileys/arduino/huh.gif)
before started purging, when compiled project got following (on mega 2560 compiled on version 1.0).....
quote
binary sketch size: 128420 bytes (of 258048 byte maximum)
i removed of redundant progmem statements precompiler directive....
code: [select]
//#define waste_of_space
#ifdef waste_of_space
const prog_char igc_line_001[] progmem = "b1255275225709n00105715wa006780074700309";
const prog_char igc_line_002[] progmem = "b1255315225644n00105791wa006750074500310";
const prog_char igc_line_003[] progmem = "b1255355225559n00105822wa006780074300310";
const prog_char igc_line_004[] progmem = "b1255395225479n00105779wa006830074900310";
const prog_char igc_line_005[] progmem = "b1255435225439n00105682wa006830074900210";
const prog_char igc_line_006[] progmem = "b1255475225453n00105595wa006830074600210";
const prog_char igc_line_007[] progmem = "b1255515225496n00105563wa006860074900211";
const prog_char igc_line_008[] progmem = "b1255555225538n00105554wa006870075200211";
const prog_char igc_line_009[] progmem = "b1255595225567n00105615wa006900075300210";
const prog_char igc_line_010[] progmem = "b1256035225535n00105703wa006940075900210";
const prog_char igc_line_011[] progmem = "b1256075225455n00105720wa006950076000210";
const prog_char igc_line_012[] progmem = "b1256115225389n00105648wa006950076000209";
const prog_char igc_line_013[] progmem = "b1256155225372n00105548wa007050076800211";
const prog_char igc_line_014[] progmem = "b1256195225398n00105485wa007010076800210";
const prog_char igc_line_015[] progmem = "b1256235225440n00105489wa007010076300211";
const prog_char igc_line_016[] progmem = "b1256275225465n00105556wa007070076900211";
const prog_char igc_line_017[] progmem = "b1256315225439n00105646wa007140077600211";
const prog_char igc_line_018[] progmem = "b1256355225365n00105678wa007210078600211";
const prog_char igc_line_019[] progmem = "b1256395225297n00105611wa007210078600210";
const prog_char igc_line_020[] progmem = "b1256435225280n00105510wa007290079100211";
const prog_char igc_line_021[] progmem = "b1256475225307n00105448wa007290079400210";
const prog_char igc_line_022[] progmem = "b1256515225347n00105460wa007350079700211";
const prog_char igc_line_023[] progmem = "b1256555225358n00105534wa007420080400210";
const prog_char igc_line_024[] progmem = "b1256595225312n00105608wa007470081200209";
const prog_char igc_line_025[] progmem = "b1257035225233n00105607wa007540081500211";
const prog_char igc_line_026[] progmem = "b1257075225173n00105528wa007550081900210";
const prog_char igc_line_027[] progmem = "b1257115225168n00105427wa007530081700211";
const prog_char igc_line_028[] progmem = "b1257155225209n00105390wa007580081900211";
const prog_char igc_line_029[] progmem = "b1257195225241n00105441wa007620082500210";
const prog_char igc_line_030[] progmem = "b1257235225219n00105536wa007690082900210";
const prog_char igc_line_031[] progmem = "b1257275225145n00105573wa007740083400210";
const prog_char igc_line_032[] progmem = "b1257315225072n00105520wa007830084300210";
const prog_char igc_line_033[] progmem = "b1257355225038n00105419wa007810084300211";
const prog_char igc_line_034[] progmem = "b1257395225056n00105335wa007820084300209";
const prog_char igc_line_035[] progmem = "b1257435225099n00105328wa007880084900211";
const prog_char igc_line_036[] progmem = "b1257475225120n00105395wa007900085200210";
const prog_char igc_line_037[] progmem = "b1257515225085n00105482wa007970085700210";
#endif
when compile
quote
binary sketch size: 128414 bytes (of 258048 byte maximum)
so i've saved myself massive 6 bytes!
is because compiler can't add up? or check if strings used in project anywhere before attempting allocate space? (all strings in above example stopped using ages ago, lazy remove @ time)
at moment have single file put progmem declarations in, , include 1 file in of projects. save compile space in largest project thinking of removing irrelevant stuff, if compiler checking if each string used, guess isn't going make difference?
cheers
progmem directives save copying data program memory (the sketch memory) ram @ startup. data there, using progmem saves taking ram.
there known problems mega , large arrays, don't recall thread, try searching it.
as saving memory, compiler optimizes away stuff don't use, #ifdef doesn't achieve much.
there known problems mega , large arrays, don't recall thread, try searching it.
as saving memory, compiler optimizes away stuff don't use, #ifdef doesn't achieve much.
Arduino Forum > Using Arduino > Programming Questions > Where does PROGMEM stuff go?
arduino
Comments
Post a Comment