HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- const data and pmap output and "+Olit" option
Operating System - HP-UX
1832958
Members
2750
Online
110048
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2009 06:31 AM
09-05-2009 06:31 AM
const data and pmap output and "+Olit" option
Hi ,
I am trying to optimise memory utilisation for my program
There are some read only arrays in applications which have been declared as static . I changed them to const .
when created shared library ; i got difference in size command , but pmap does not show any difference
----> stats.c
#include
const int x[] = {0 ,1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9 ,10 ,11 ,12 ,13 ,14 ,15 ,16 ,17 ,18 ,19 ,20 ,21 ,22 ,23 ,24 ,25 ,26
,27 ,28 ,29 ,30 ,31 ,32 ,33 ,34 ,35 ,36 ,37 ,38 ,39 ,40 ,41 ,42 ,43 ,44 ,45 ,46 ,47 ,48 ,49 ,50 ,51 ,52 ,53 ,54 ,5
5 ,56 ,57 ,58 ,59 ,60 ,61 ,62 ,63 ,64 ,65 ,66 ,67 ,68 ,69 ,70 ,71 ,72 ,73 ,74 ,75 ,76 ,77 ,78 ,79 ,80 ,81 ,82 ,83
,84 ,85 ,86 ,87 ,88 ,89 ,90 ,91 ,92 ,93 ,94 ,95 ,96 ,97 ,98 ,99 ,100 ,101 ,102 ,103 ,104 ,105 ,106 ,107 ,108 ,109
,110 ,111 ,112 ,113 ,114 ,115 ,116 ,117 ,118 ,119 ,120 ,121 ,122 ,123 ,124 ,125 ,126 ,127 ,128 ,129 ,130 ,131 ,132
,133 ,134 ,135 ,136 ,137 ,138 ,139 ,140 ,141 ,142 ,143 ,144 ,145 ,146 ,147 ,148 ,149 ,150 ,151 ,152 ,153 ,154 ,15
5 ,156 ,157 ,158 ,159 ,160 ,161 ,162 ,163 ,164 ,165 ,166 ,167 ,168 ,169 ,170 ,171 ,172 ,173 ,174 ,175 ,176 ,177 ,1
78 ,179 ,180 ,181 ,182 ,183 ,184 ,185 ,186 ,187 ,188 ,189 ,190 ,191 ,192 ,193 ,194 ,195 ,196 ,197 ,198 ,199 ,200 ,
201 ,202 ,203 ,204 ,205 ,206 ,207 ,208 ,209 ,210 ,211 ,212 ,213 ,214 ,215 ,216 ,217 ,218 ,219 ,220 ,221 ,222 ,223
,224 ,225 ,226 ,227 ,228 ,229 ,230 ,231 ,232 ,233 ,234 ,235 ,236 ,237 ,238 ,239 ,240 ,241 ,242 ,243 ,244 ,245 ,246
,247 ,248 ,249 ,250 ,251 ,252 ,253 ,254 ,255 ,256 ,257 ,258 ,259 ,260 ,261 ,262 ,263 ,264 ,265 ,266 ,267 ,268 ,26
9 ,270 ,271 ,272 ,273 ,274 ,275 ,276 ,277 ,278 ,279 ,280 ,281 ,282 ,283 ,284 ,285 ,286 ,287 ,288 ,289 ,290 ,291 ,2
92 ,293 ,294 ,295 ,296 ,297 ,298 ,299 };
static int y = 0;
void dummy()
{
int z;
z=x[0];
printf(" Value of [%d]\n",z);
y++;
printf("Inside dummy %d\n",y);
}
-------------------------------end of stats3.so
int main(int arcg, char* argv[]) {
void * hndl = (void *)0;
void * func = (void *)0;
int ret = 0;
void (*f)();
hndl=dlopen("./stats3.so",RTLD_LAZY|RTLD_GLOBAL);
/*hndl=dlopen("/finacle/fincore/v10.22BT1/runtime/mbdapirel/prodbase/exe/finlistvalrtn_fab.so",RTLD_LAZY|R
TLD_GLOBAL);*/
/*hndl=dlopen(argv[1],RTLD_LAZY|RTLD_GLOBAL);*/
if (hndl == NULL) {
printf("Unable to load library dlerror [%s]\n", dlerror());
exit(-256);
}
f =(void (*)())dlsym(hndl,"dummy");
if ( f == NULL)
{
printf(" f is null\n");
}
else
{
f();
}
} // end of main
size command with const
text data bss dec hex filename
2140 28 24 2192 890 stats3.so
size command with static arrays instead of const
938 1236 24 2198 896 stats1.so
But when i load these SO using loadlib program
I don't see any difference in pmap output .i was expecting that data and text memory map would be exchanged in case of static and const data . Tried with +Olit=all compiler option . But same result i could see.
502: loadlib
OFFSET VSZ RSZ TYPE PRM FILE
0 4K 4K SD(735) r-- [nullderef]
4000000 4K 4K SC(3) r-x [text]
40010000 32K 28K PD rw- [data]
678d6000 4K 4K PD rw- /users3/e51569/finaclelite/olit/stats3.so
678d7000 4K 4K PD rw- [anonymous]
678d8000 16K 16K PD rwx [anonymous]
678dc000 32K 32K PD rw- /usr/lib/hpux32/libc.so.1
678e4000 48K 48K PD rw- [anonymous]
678f0000 16K 16K PD rwx [anonymous]
678f4000 8K 8K PD rwx [anonymous]
678f6000 4K 4K PD rw- /usr/lib/hpux32/libdl.so.1
678f7000 12K 12K PD rw- /usr/lib/hpux32/dld.so
678fa000 8K 8K PD rw- [anonymous]
678fc000 8K 8K PD rwx [anonymous]
678fe000 4K 4K PD rw- /usr/lib/hpux32/uld.so
678ff000 8K 4K PD rw- [rsestack]
68100000 64K 64K PD rw- [stack]
c0004000 64K 60K SC(691) --x /usr/lib/hpux32/uld.so
c0014000 560K 560K SC(692) r-x /usr/lib/hpux32/dld.so
c01a4000 2820K 2776K SC(692) r-x /usr/lib/hpux32/libc.so.1
c0468000 16K 16K SC(692) r-x /usr/lib/hpux32/libdl.so.1
c07ff000 4K 4K SC(3) r-x /users3/e51569/finaclelite/olit/stats3.so
9fffffff7f7df000 72K 64K PD rw- [uarea]
I am trying to optimise memory utilisation for my program
There are some read only arrays in applications which have been declared as static . I changed them to const .
when created shared library ; i got difference in size command , but pmap does not show any difference
----> stats.c
#include
const int x[] = {0 ,1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9 ,10 ,11 ,12 ,13 ,14 ,15 ,16 ,17 ,18 ,19 ,20 ,21 ,22 ,23 ,24 ,25 ,26
,27 ,28 ,29 ,30 ,31 ,32 ,33 ,34 ,35 ,36 ,37 ,38 ,39 ,40 ,41 ,42 ,43 ,44 ,45 ,46 ,47 ,48 ,49 ,50 ,51 ,52 ,53 ,54 ,5
5 ,56 ,57 ,58 ,59 ,60 ,61 ,62 ,63 ,64 ,65 ,66 ,67 ,68 ,69 ,70 ,71 ,72 ,73 ,74 ,75 ,76 ,77 ,78 ,79 ,80 ,81 ,82 ,83
,84 ,85 ,86 ,87 ,88 ,89 ,90 ,91 ,92 ,93 ,94 ,95 ,96 ,97 ,98 ,99 ,100 ,101 ,102 ,103 ,104 ,105 ,106 ,107 ,108 ,109
,110 ,111 ,112 ,113 ,114 ,115 ,116 ,117 ,118 ,119 ,120 ,121 ,122 ,123 ,124 ,125 ,126 ,127 ,128 ,129 ,130 ,131 ,132
,133 ,134 ,135 ,136 ,137 ,138 ,139 ,140 ,141 ,142 ,143 ,144 ,145 ,146 ,147 ,148 ,149 ,150 ,151 ,152 ,153 ,154 ,15
5 ,156 ,157 ,158 ,159 ,160 ,161 ,162 ,163 ,164 ,165 ,166 ,167 ,168 ,169 ,170 ,171 ,172 ,173 ,174 ,175 ,176 ,177 ,1
78 ,179 ,180 ,181 ,182 ,183 ,184 ,185 ,186 ,187 ,188 ,189 ,190 ,191 ,192 ,193 ,194 ,195 ,196 ,197 ,198 ,199 ,200 ,
201 ,202 ,203 ,204 ,205 ,206 ,207 ,208 ,209 ,210 ,211 ,212 ,213 ,214 ,215 ,216 ,217 ,218 ,219 ,220 ,221 ,222 ,223
,224 ,225 ,226 ,227 ,228 ,229 ,230 ,231 ,232 ,233 ,234 ,235 ,236 ,237 ,238 ,239 ,240 ,241 ,242 ,243 ,244 ,245 ,246
,247 ,248 ,249 ,250 ,251 ,252 ,253 ,254 ,255 ,256 ,257 ,258 ,259 ,260 ,261 ,262 ,263 ,264 ,265 ,266 ,267 ,268 ,26
9 ,270 ,271 ,272 ,273 ,274 ,275 ,276 ,277 ,278 ,279 ,280 ,281 ,282 ,283 ,284 ,285 ,286 ,287 ,288 ,289 ,290 ,291 ,2
92 ,293 ,294 ,295 ,296 ,297 ,298 ,299 };
static int y = 0;
void dummy()
{
int z;
z=x[0];
printf(" Value of [%d]\n",z);
y++;
printf("Inside dummy %d\n",y);
}
-------------------------------end of stats3.so
int main(int arcg, char* argv[]) {
void * hndl = (void *)0;
void * func = (void *)0;
int ret = 0;
void (*f)();
hndl=dlopen("./stats3.so",RTLD_LAZY|RTLD_GLOBAL);
/*hndl=dlopen("/finacle/fincore/v10.22BT1/runtime/mbdapirel/prodbase/exe/finlistvalrtn_fab.so",RTLD_LAZY|R
TLD_GLOBAL);*/
/*hndl=dlopen(argv[1],RTLD_LAZY|RTLD_GLOBAL);*/
if (hndl == NULL) {
printf("Unable to load library dlerror [%s]\n", dlerror());
exit(-256);
}
f =(void (*)())dlsym(hndl,"dummy");
if ( f == NULL)
{
printf(" f is null\n");
}
else
{
f();
}
} // end of main
size command with const
text data bss dec hex filename
2140 28 24 2192 890 stats3.so
size command with static arrays instead of const
938 1236 24 2198 896 stats1.so
But when i load these SO using loadlib program
I don't see any difference in pmap output .i was expecting that data and text memory map would be exchanged in case of static and const data . Tried with +Olit=all compiler option . But same result i could see.
502: loadlib
OFFSET VSZ RSZ TYPE PRM FILE
0 4K 4K SD(735) r-- [nullderef]
4000000 4K 4K SC(3) r-x [text]
40010000 32K 28K PD rw- [data]
678d6000 4K 4K PD rw- /users3/e51569/finaclelite/olit/stats3.so
678d7000 4K 4K PD rw- [anonymous]
678d8000 16K 16K PD rwx [anonymous]
678dc000 32K 32K PD rw- /usr/lib/hpux32/libc.so.1
678e4000 48K 48K PD rw- [anonymous]
678f0000 16K 16K PD rwx [anonymous]
678f4000 8K 8K PD rwx [anonymous]
678f6000 4K 4K PD rw- /usr/lib/hpux32/libdl.so.1
678f7000 12K 12K PD rw- /usr/lib/hpux32/dld.so
678fa000 8K 8K PD rw- [anonymous]
678fc000 8K 8K PD rwx [anonymous]
678fe000 4K 4K PD rw- /usr/lib/hpux32/uld.so
678ff000 8K 4K PD rw- [rsestack]
68100000 64K 64K PD rw- [stack]
c0004000 64K 60K SC(691) --x /usr/lib/hpux32/uld.so
c0014000 560K 560K SC(692) r-x /usr/lib/hpux32/dld.so
c01a4000 2820K 2776K SC(692) r-x /usr/lib/hpux32/libc.so.1
c0468000 16K 16K SC(692) r-x /usr/lib/hpux32/libdl.so.1
c07ff000 4K 4K SC(3) r-x /users3/e51569/finaclelite/olit/stats3.so
9fffffff7f7df000 72K 64K PD rw- [uarea]
1 REPLY 1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2009 09:46 PM
09-05-2009 09:46 PM
Re: const data and pmap output and "+Olit" option
>I changed them to const.
Better to be both, even if you are using C++: static const
>I got difference in size command
Then you have solved the problem.
>exit(-256);
You are limited to values 0 .. 255.
>pmap does not show any difference
>I was expecting that data and text memory map would be exchanged in case of static and const data.
Where is your before and after? Unless your data size is many pages, you may not notice it.
What do you mean exchanged? What happens is text increases and data decreases.
>Tried with +Olit=all compiler option.
That's now the default.
Here are your stats3.so regions:
678d6000 4K 4K PD rw- stats3.so
678d7000 4K 4K PD rw- [anonymous]
c07ff000 4K 4K SC(3) r-x stats3.so
Each region is 1 page.
Better to be both, even if you are using C++: static const
>I got difference in size command
Then you have solved the problem.
>exit(-256);
You are limited to values 0 .. 255.
>pmap does not show any difference
>I was expecting that data and text memory map would be exchanged in case of static and const data.
Where is your before and after? Unless your data size is many pages, you may not notice it.
What do you mean exchanged? What happens is text increases and data decreases.
>Tried with +Olit=all compiler option.
That's now the default.
Here are your stats3.so regions:
678d6000 4K 4K PD rw- stats3.so
678d7000 4K 4K PD rw- [anonymous]
c07ff000 4K 4K SC(3) r-x stats3.so
Each region is 1 page.
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP