Stack and heap allocation checking LPC1114

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

Stack and heap allocation checking LPC1114

1,394件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by JSalisbury on Thu Jul 14 03:49:45 MST 2011
Hi,
What is the best way of checking the stack and heap allocation in my C code for the LPC1114? Are there any tools that could assist with this?

Thanks
0 件の賞賛
返信
4 返答(返信)

1,306件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by CodeRedSupport on Thu Sep 29 07:05:23 MST 2011
Assuming  that you are using LPCXpresso 4, then depending upon what you are actually trying to do, you may find the section on "Heap allocation/checking" in the following FAQ of use...

http://support.code-red-tech.com/CodeRedWiki/redlib_v2_notes

Regards,
CodeRedSupport.
0 件の賞賛
返信

1,306件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by rompacz on Thu Sep 29 02:19:33 MST 2011
Hi guys,
I have similar question. I want to control memory alocation after using malloc() function. Do you know how to do it?

I can imagine something like that:

memory_left_1=function();
malloc(200);
memory_left_2=function();

After that,  memory_left_2 would be 200 bytes less than memory_left_1.

In stack usage example, it is possible only to control the stack size. In my case, I need to control the heap size, I guess.
0 件の賞賛
返信

1,306件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by StephenHawkings on Sat Jul 16 04:42:33 MST 2011
There's an example included, which is called "stackusage". It contains also information about heap.

C:\nxp\LPCXpresso_4.0.5_123\lpcxpresso\Examples\NXP\LPC1000\LPC11xx\NXP_LPCXpresso1114-302_2011-02-07\stackusage

Best regards!
SH
0 件の賞賛
返信

1,306件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by jharwood on Fri Jul 15 22:10:24 MST 2011
Maybe not completely accurate, but near enough: is to use memory 'painting'.

In the ResetISR() function within the C run-time startup code, fill the memory from the end of the .bss section up to the top of RAM with a pattern value. Perhaps something like: {0xD, 0xE, 0xA, 0xD, 0xC, 0x0, 0xD, 0xE} if done with 32-bit words.

Then, when you want to check memory usage, start at the top of RAM, working your way down, look for two (or more) contiguous occurrences of the pattern value. That will pin-point the stack "high water mark". (or "low water mark" if you want to think of it that way)

Continue down from there, looking for two (or more) contiguous non-occurrences of the pattern. That would pin-point the top of the heap.

You would probably have to make a point of always initializing heap allocations to all zeroes so that recent allocations would clear the painting pattern.

HTH, james
0 件の賞賛
返信