cancel
Showing results for 
Search instead for 
Did you mean: 

pmap - anonymous segment

 
Highlighted
Occasional Advisor

pmap - anonymous segment

Hi ,

Have a created sample dynamic SO using sample program

void manipulate()
{
printf("Hello\n");
return;
}

If i load this SO , using dlopen and do pmap on this SO , i get following below which i did not expect , as i don't have any variables i did not expect any private Data taken at loading.

When we did pmap after loading SO , we still got anonymous data of 108 KBS
FILE VSZ
[anonymous] 4K PD
[anonymous] 16K PD
[anonymous] 48K PD
[anonymous] 16K PD
[anonymous] 8K PD
[anonymous] 8K PD
[anonymous] 8K PD

What does this anonymous segments signify.
6 REPLIES 6
Highlighted
Acclaimed Contributor

Re: pmap - anonymous segment

>Have a created sample dynamic SO

(These are called shared libs on HP-UX.)

>I don't have any variables I did not expect any private Data taken at loading.

Even if you have no data, you need a linkage table to call things and to reference that string.

>What does this anonymous segments signify?

You have to track down the callers.
Typically shlibs may have two private mmaps, one for data and one for bss.
Thread stacks are also mmapped.

Also, dld needs mmaps for its symbol table, possibly those 8 K ones.
Highlighted
Occasional Advisor

Re: pmap - anonymous segment

Hi ,

i am trying to optimise memory utilisation of my application ( which is very huge in terms of LOC , millions of lines of code) .

Anonymous segments are shown even if i have global variables .
in such cases how to distinguish
memory taken by
1) dynamic loader
2) application variable .
Ideally memory taken by dynamic loader should have been shared Data and not private Data .

Regards
Tanmay
Highlighted
Acclaimed Contributor

Re: pmap - anonymous segment

>I am trying to optimise memory utilisation of my application

Code is free, how many Mb of data do you have? How many simultaneous users will you have?

>Anonymous segments are shown even if I have global variables.

Naturally. All shlib static storage duration data is mmapped private.

>in such cases how to distinguish memory taken by
1) dynamic loader
2) application variable.

If the size is based on the output of size(1), then it is user data, otherwise it is dld, thread stacks or application mmap(2) calls. If it shows up in gdb's "info shared", then it is 2).

Or as a gedanken experiment, increase the size of your data to N Mb and anything smaller is dld's.

>Ideally memory taken by dynamic loader should have been shared Data and not private Data.

Why would you think that? This is process specific data and must be private. Only text is mapped shared.
Highlighted
Occasional Advisor

Re: pmap - anonymous segment

Hi ,

Have millons of lines of code in my application . it would not be possible to change the code .
Will have 1200 users connecting to my application.
Highlighted
Acclaimed Contributor

Re: pmap - anonymous segment

>Have millions of lines of code in my application.

I'm saying that the cost of code is nearly "free", it is only data that matters.

>Will have 1200 users connecting to my application.

So every data item is multiplied by 1200.
Unless you change your application to use threads and not processes. Or use shared memory.
Highlighted
Occasional Advisor

Re: pmap - anonymous segment

I have received inhouse tool from HP folks which actually shows regions of memory occupied by shared memory . What pmap shows is program memory + kernel memory .