Skip to contentSkip to conversation

Help understanding memory layout

DISCUSSION Phy Prabab 3 participants 3 messages Oct 28, 2004

lore
Share & tools
lore

Phy Prabab

author
#0 lore raw

Hello,

I need some help understanding memory layout of applications within memory under linux. I am using the command "pmap" to understand where all the elements of my application are laying and found that I just do not understand how and why it is layed out in a particular fashion. Is there documentation that could help me understand memory management under Linux?

Thank you for your time.
Phy

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

#1 lore raw
Quoted 11 lines · Phy Prabab

Hello,

I need some help understanding memory layout of applications within memory under linux. I am using the command "pmap" to understand where all the elements of my application are laying and found that I just do not understand how and why it is layed out in a particular fashion. Is there documentation that could help me understand memory management under Linux?

Quoted 2 lines

Thank you for your time.
Phy

You can look in /proc/PID/maps to see where memory-mapped stuff exists. PID is the process-ID number.

You can also use printf("%p\n", function); to get the offset of any function in your code. Using this same method, you can also print the offset of anything that can be labeled in your code.

These offsets are only useful for mental masturbation. If your application needs to know the layout of its code and data it is severely broken and needs to be fixed. All data elements are accessible using conventional language methods such as pointers, array elements, and structure members.

Cheers,
Dick Johnson
Penguin : Linux version 2.6.9 on an i686 machine (5537.79 BogoMips).
Notice : All mail here is now cached for review by John Ashcroft.
98.36% of all statistics are fiction.