EmbDev.net

Forum: ARM programming with GCC/GNU tools View memory allocation


Author: Thejus Kuttian (thejus)
Posted on:

Rate this post
0 useful
not useful
hi,


I have a C source code .I have created an elf image using the source
code along with startup code and linkerscript. I want to view the memory
partion ie, length of code segment , data segment stack and heap.Is
there any methode to view the allocated memory (ie, segment based
addresses)?.

Is there any way to monitor the heap allocation , ( to avoid the stack
heap overlapping)?

regards
thejus

Author: Clifford Slocombe (clifford)
Posted on:

Rate this post
0 useful
not useful
The linker can output a map file to show memory organisation of your
code with teh following option:

-Map <mapfile>

With respect to heap monitoring. The sbrk()/sbrk_r() syscall function is
ultimately how the system aquired heap. You have te implement this
yourself (or use one of the examples), you can add code here to perform
monitoring operations, but it is normally written to be bounded to a
defined memory region. Of greater concern would be stack overflow, since
that is more difficult to guard against. A common approach is to
pre-fill the stack segment with a known and repeated value or sequence
of values, then to determine stack usage, scan the segment to test for
the 'high warter mark'.

Clifford

Author: Thejus Kuttian (thejus)
Posted on:

Rate this post
0 useful
not useful
hi Clifford,

Actually i am using so many pointers (some size up to 8mb). So if there
is a way to view the heap allocation we can judge whether heap over
writes the stack. am i right?

What is the difference between hw stack and sw stack.? how can we know
exactly how much space is required for stack (in hw).

regards
thejus



Clifford Slocombe wrote:
> The linker can output a map file to show memory organisation of your
> code with teh following option:
>
> -Map <mapfile>
>
> With respect to heap monitoring. The sbrk()/sbrk_r() syscall function is
> ultimately how the system aquired heap. You have te implement this
> yourself (or use one of the examples), you can add code here to perform
> monitoring operations, but it is normally written to be bounded to a
> defined memory region. Of greater concern would be stack overflow, since
> that is more difficult to guard against. A common approach is to
> pre-fill the stack segment with a known and repeated value or sequence
> of values, then to determine stack usage, scan the segment to test for
> the 'high warter mark'.
>
> Clifford

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.