Problem: C Strings occupy RAM space

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

Problem: C Strings occupy RAM space

Jump to solution
1,057 Views
jluis
Contributor I

Hi everybody,

 

I'm using a lot of strings in my code, and I suppose that this string must remain into flash mamory. But the strings are occuping a lot of RAM space. How can I avoid that?

 

Thanks an best regards!

Labels (1)
Tags (1)
0 Kudos
1 Solution
428 Views
CompilerGuru
NXP Employee
NXP Employee

I created a new stationery project for the V1 QE128 and used a string in main.c.

The string gets allocated in flash just as code is, so I wonder if you have some other special setup or if your diagnosis that the string ends up using RAM is not correct and the RAM is eaten up by something else.

 

Here's what I got out of the xmap file:

 

  000007D8 0000000C .text   _ewl_exit (librt.a abort_exit.o   )  000007E4 00000009 .rodata @8 (main.c)

 As you see the string ends up in .rodata just after the last code function from .text .

 As you see the strings also ending up in .rodata (good) is the issue that your lcf places .rodata inproperly?

 

 Daniel

 

 

 

 

 

View solution in original post

0 Kudos
3 Replies
428 Views
jluis
Contributor I

Hello,

 

the target processor is a ColdFire V1 (QE128), I´m using CodeWarrior V6.2.

 

I´m using a lot of strings in my code, for example:

 

strstr(myBuffer, "MyString");

 

When I compile the proyect, in the proyect window says that I have a lot of RAM usage, while only are declared a few variables.

 

In the .MAP file, these strings appears into the .rodata section.

 

How can I avoid this behaivor?

 

thanks in advance!

 

0 Kudos
429 Views
CompilerGuru
NXP Employee
NXP Employee

I created a new stationery project for the V1 QE128 and used a string in main.c.

The string gets allocated in flash just as code is, so I wonder if you have some other special setup or if your diagnosis that the string ends up using RAM is not correct and the RAM is eaten up by something else.

 

Here's what I got out of the xmap file:

 

  000007D8 0000000C .text   _ewl_exit (librt.a abort_exit.o   )  000007E4 00000009 .rodata @8 (main.c)

 As you see the string ends up in .rodata just after the last code function from .text .

 As you see the strings also ending up in .rodata (good) is the issue that your lcf places .rodata inproperly?

 

 Daniel

 

 

 

 

 

0 Kudos
428 Views
CompilerGuru
NXP Employee
NXP Employee

Which processor are you targeting? Which tools are using?

And how do you use the string constants? Can you provide a sample application?

 

Daniel

0 Kudos