Static const in RAM in debug mode

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Static const in RAM in debug mode

545 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by PoolCop on Wed Jun 01 04:05:16 MST 2016
Hello all,

I'm currently developing a project with a lot of constant strings (for a multi languages user interface) on NXP1768 , LPCXpresso V8.1.4

example of string definition:
//   Define language id.
static const char * lang_text[10]= {"EN","FR","NL","IT","TK","DE","SP","PT","??","??"};


When the project is  compiled in Release mode, strings declared as static const, are store in flash memory.
When I try to compile in debug mode, looks like a copy of these "static const" is made in RAM and therefore RAM usage goes from 15% (Release) to close 98%(Debug).
I guess this is for the debug probe to access these data...

Memory region         Used Size  Region Size  %age Used
       MFlash512:      223092 B       512 KB     42.55%
        RamLoc32:       32132 B        32 KB     98.06%
        RamAHB32:          0 GB        32 KB      0.00%


I still need to complete the project and will soon face a RAM issue in Debug.

Is there a way (compiler option...) to tweak the Debug version so that these data are not copied into RAM ?

Thanks
René
0 Kudos
3 Replies

420 Views
lpcware
NXP Employee
NXP Employee
bump
0 Kudos

420 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by wmues on Fri Jun 03 01:06:48 MST 2016
Try this:

static const char * const lang_text[10]= {"EN","FR","NL","IT","TK","DE","SP","PT","??","??"};

This is a const array of pointers to const chars. Without the 2nd "const", the array is writeable and has to be in RAM.

Coding error.

0 Kudos

420 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Wed Jun 01 04:11:39 MST 2016
Just change optimization  :O  :quest:
0 Kudos