Problem: C Strings occupy RAM space

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Problem: C Strings occupy RAM space

ソリューションへジャンプ
1,066件の閲覧回数
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!

ラベル(1)
タグ(1)
0 件の賞賛
1 解決策
437件の閲覧回数
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 件の賞賛
3 返答(返信)
437件の閲覧回数
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 件の賞賛
438件の閲覧回数
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 件の賞賛
437件の閲覧回数
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 件の賞賛