EmbDev.net

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


von Thejus K. (thejus)


Rate this post
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

von Clifford S. (clifford)


Rate this post
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

von Thejus K. (thejus)


Rate this post
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

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.