cancel
Showing results for 
Search instead for 
Did you mean: 

Heap fragementation on HPUX

SOLVED
Go to solution
Atul Goel
Frequent Advisor

Heap fragementation on HPUX

The Resident size(as observed from top) of my process is increasing. But, the behaviour is very random. My process works on request reponse model. So when i put some request load on my process the memory starts increasing. For initial few hours (approx ~3 hrs) it increase at a rapid rate and after that increase become stable. Some time after 30 min a 16 kb increase is observed some time after 2-3 hrs. And some times an increase of even 128kb is observed. Behaviour is really random. Attached are the some graph of resident memory of process taken at interval of 10 min each.

I tried wdb in BATCH mode with my process. But, it didnot detected any leaks. It produced only heap profile files.

Is there any way to find out that the wt=hether increase is due to fragmentation? Because lot of malloc are happening in my process.
Platform is HP-UX B.11.23 on HP itanium server. I can use wdb and glance tool(I only have working knowledge of both of these :( )

Also, considering the fact that memory increase is after 2-3 hr run how can i work with wdb in debugger mode. Means is it possible to automate printing the heap information and continuing from that point in gdb/wdb automatically?
21 REPLIES
James R. Ferguson
Acclaimed Contributor

Re: Heap fragementation on HPUX

Hi:

The heap (from 'malloc' and cousins) may grow, but it will not shrink. When 'malloc()'ed memory is 'free()'ed that memory is returned to the heap, but not to the system until the process terminates.

Regards!

...JRF...
Steven E. Protter
Exalted Contributor

Re: Heap fragementation on HPUX

Shalom,

Did you try my handy dandy memory leak detector?

http://www.hpux.ws/?p=8

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Atul Goel
Frequent Advisor

Re: Heap fragementation on HPUX

Hi James,
Thanks for quick reply. But, how to ensure that there is no memory leak. Because, if i monitor process for say 7 hr or 8 hrs i can see some jumps of memory increase in 16kb chunks.

I have to prove that there is no memory leak but i cannot integrate with any tool like purify which need recompilation due to some techinal difficaulties
Atul Goel
Frequent Advisor

Re: Heap fragementation on HPUX

Hi Steven

Your tool will tell which process is taking memory. I know there is an increase in memory of my process but i am not sure wether it is because of memory leak or something else
Dennis Handly
Acclaimed Contributor

Re: Heap fragementation on HPUX

>The Resident size (as observed from top) of my process is increasing.

(You don't care about Resident size, just the total size but I assume both are increasing.)

>it did not detected any leaks. It produced only heap profile files. ... Is there any way to find out that the whether increase is due to fragmentation?

Then you either have heap fragmentation or your heap usage is increasing. Did wdb say whether your heap allocation was increasing or just the arena and free areas? The latter is heap fragmentation. (Are you using threads?)

Fragmentation can also be detected by mallinfo(3).

>I only have working knowledge of both of these

Have you looked at the WDB document: Debugging dynamic memory usage errors using HP WDB
http://www.hp.com/go/wdb

>is it possible to automate printing the heap information and continuing from that point in gdb/wdb automatically?

You can also call mallinfo(3).

>I have to prove that there is no memory leak but I cannot integrate with any tool like purify which need recompilation

No need to use purify. wdb/mallinfo(3) will tell you if you have leaks but not where.
Also, whether you have a leak or heap fragmentation, the result is the same, except instead of blaming your application, you blame libc. :-) Or you need to change how you allocate space

You may want to use MallocNextGen:
http://h20392.www2.hp.com/portal/swdepot/displayProductInfo.do?productNumber=MallocNextGen

It does a better job if you have threads.


>JRF: The heap may grow, but it will not shrink.

If Atul mentions "Heap fragmentation" he probably knows about this. He needs to look for zebras. ;-)
Laurent Menase
Honored Contributor

Re: Heap fragementation on HPUX

if it is fragmentation problems you can play with mallopt() to specify how small block allocator should behave.

you can also make tests with _M_SBA_OPTS env variable to test various sba configs.

Atul Goel
Frequent Advisor

Re: Heap fragementation on HPUX

Hi Dennis

Thanks for the detailed information. But, when you say "Also, whether you have a leak or heap fragmentation, the result is the same" do you mean we cannot distinguish between the two. I hope there should be some way to distinguish between fragmentation and leak and i am looking for the same
Atul Goel
Frequent Advisor

Re: Heap fragementation on HPUX

Hi Laurent

Can you please more information regarding this "_M_SBA_OPTS" variable. Or can you point to some good links regarding this option
Laurent Menase
Honored Contributor

Re: Heap fragementation on HPUX

The only doc I know is man malloc
Dennis Handly
Acclaimed Contributor

Re: Heap fragementation on HPUX

>when you say "whether you have a leak or heap fragmentation, the result is the same" do you mean we cannot distinguish between the two.

I told you how, mallinfo(3). But to your management (PHB :-), the results are the same, you can't run your application.

>Can you please more information regarding this "_M_SBA_OPTS" variable.

http://docs.hp.com/en/B2355-60130/malloc.3C.html#d0e833111

Again, do you have threads?
Have you installed MallocNextGen?

>Laurent: if it is fragmentation problems you can play with mallopt() to specify how small block allocator should behave.

Right, SBA is on by default. It may be the big blocks that are fragmented so you may have to increase maxfast to include more blocks as "small". You might be able to see this in gdb's "info heap".
Atul Goel
Frequent Advisor

Re: Heap fragementation on HPUX

Following is the heap profile of one run
Can you figure out something
***********************************

Actual Heap Usage:
Heap Start = 0x40113a58
Heap End = 0x44ba0000
Heap Size = 78169512 bytes

Outstanding Allocations:
52961479 bytes allocated in 136358 blocks

No. Total bytes Blocks Address Function
0 32782336 512 0x440efb40 init_buffers()
1 7111744 16400 0x41c01ce0 wmalloc_port()
2 2361904 16424 0x4200dae0 wmalloc_port()
3 2048896 32 0x44916940 init_buffers()
4 2048896 32 0x421710f0 init_buffers()
5 1968000 16400 0x41c673d0 wmalloc_port()
6 1265664 256 0x446ebbb0 init_cinfos()
7 1024000 25600 0x4456bcb0 init_buffers()
8 512000 12800 0x44a427f0 init_buffers()
9 512000 12800 0x4242d6e0 init_buffers()
10 393264 8193 0x41bc6fb0 wmalloc_port()
11 393264 8193 0x414f1100 wmalloc_port()
12 98316 8193 0x42067540 wmalloc_port()
13 98316 8193 0x41842230 wmalloc_port()
14 79104 16 0x424933c0 init_cinfos()
15 79104 16 0x44ab0e10 init_cinfos()
16 17324 1 0x42494f70 SLDB_Manager_create()
17 14336 512 0x427ae800 init_buffers()
18 12800 200 0x44b850f0 RT_allocateNode()
19 12420 5 0x4249c400 DSS_Manager_create()
20 11900 1 0x44761be0 CFGXX_load_file()
21 10624 1 0x4475f240 CFGXX_load_file()
22 9880 65 0x40132a10 DSS_Manager_create()
23 8788 1 0x4249e0b0 MSGXX_init_module()
24 8788 1 0x4478d690 MSGXX_init_module()
25 8788 1 0x4216ee80 MSGXX_init_module()
26 8208 1 0x44ab6180 _wrtchk()
27 5380 1 0x44ab81b0 TcapMalloc()
28 4872 87 0x44b22910 wmalloc_port()
29 4480 70 0x4215cff0 RT_allocateNode()
30 3492 1 0x4111c290 __private_data_setup()
31 2400 200 0x42151960 RT_allocateNode()
32 2368 1 0x4215e380 __nss_XbyY_buf_alloc()
33 2296 41 0x44b23ae0 wmalloc_port()
34 2076 1 0x42494730 __nss_XbyY_buf_alloc()
35 2048 1 0x44b7b820 pthread_setspecific()
36 1768 221 0x421631d0 add_to_list()
37 1344 28 0x44b23e50 TcapMalloc()
38 1344 1 0x42499340 DSS_Manager_create()
39 1300 65 0x4249d260 DSS_Manager_create()
40 1248 4 0x40359ca0 wmalloc_port()
41 1172 1 0x4215ac50 do_add_host_to_lc()
42 1024 1 0x403a9100 operator new(unsigned long)
43 1024 1 0x424998a0 DSS_Manager_create()
44 948 4 0x411516b0 wmalloc_port()
45 936 3 0x4035a1e0 wmalloc_port()
46 924 21 0x44ab48b0 TimerCreation()
47 896 32 0x40365410 init_buffers()
48 896 32 0x44024200 init_buffers()
49 888 111 0x4215abc0 add_key()
50 880 110 0x421636b0 add_key()
51 840 70 0x4215b830 RT_allocateNode()
52 816 17 0x40135d80 wmalloc_port()
53 784 14 0x4214ffb0 RT_createTree()
54 568 1 0x411519c0 wmalloc_port()
55 548 1 0x4111c050 __pthread_alloc()
56 516 1 0x403a9940 wmalloc_port()
57 448 28 0x44b0d480 TcapMalloc()
58 448 28 0x44b26cd0 TcapMalloc()
59 440 1 0x42163930 getres()
60 348 29 0x44780b50 add_class()
61 336 42 0x44780b90 add_to_list()
62 324 1 0x411288a0 xUFTXX_init_uinfo()
63 320 1 0x41128740 UFTXX_init_uinfo()
64 288 1 0x421523e0 CFGXX_new_fileinfo()
65 288 1 0x421522a0 CFGXX_new_fileinfo()
66 280 5 0x42150230 wmalloc_port()
67 272 1 0x41146780 wmalloc_port()
68 264 1 0x40129050 calloc()
69 260 1 0x40129170 DSS_Manager_create()
70 256 1 0x40129290 TcapMalloc()
71 248 1 0x403a9b80 TcapMalloc()
72 232 1 0x411222c0 wmalloc_port()
73 232 1 0x411221c0 wmalloc_port()
74 232 1 0x411225c0 wmalloc_port()
75 232 1 0x411224c0 wmalloc_port()
76 232 1 0x411223c0 wmalloc_port()
77 224 4 0x421502d0 wmalloc_port()
78 224 4 0x40135b00 wmalloc_port()
79 204 17 0x403b0860 wmalloc_port()
80 188 1 0x4111d060 wmalloc_port()
81 184 1 0x44b7c050 OCTIME_init_module()
82 184 1 0x4111d130 OCTIME_init_module()
83 176 1 0x4111d200 calloc()
84 168 3 0x41bc6420 wmalloc_port()
85 168 42 0x42162290 create_list()
86 168 1 0x403550f0 __vp_alloc()
87 160 1 0x403551b0 TcapMalloc()
88 156 13 0x42160cf0 add_class()
89 144 1 0x40131780 calloc()
90 144 1 0x40131830 calloc()
91 136 1 0x411181c0 operator new[](unsigned long)
92 96 1 0x401377f0 wmalloc_port()
93 88 1 0x44b8b560 __libc_mutex_alloc()
94 88 1 0x44b8b4f0 __libc_mutex_alloc()
95 80 5 0x403650b0 calloc()
96 72 9 0x44780ff0 RT_putInFreeList()
97 70 14 0x447816f0 RT_createTree()
98 70 14 0x44781030 RT_createTree()
99 70 14 0x42160e70 RT_createTree()
100 64 1 0x40116350 __chanq_add_entry()
101 64 1 0x4215c990 COM_get_my_thread_hostent()
102 64 1 0x401164d0 wmalloc_port()
103 64 1 0x40116410 wmalloc_port()
104 64 1 0x40116470 wmalloc_port()
105 64 1 0x401163b0 wmalloc_port()
106 64 1 0x4215c9f0 do_add_routeset()
107 56 1 0x44b811b0 RT_createTree()
108 56 1 0x40136280 wmalloc_port()
109 56 1 0x4214fe20 RT_createTree()
110 54 4 0x403b06a0 wmalloc_port()
111 50 3 0x40365080 wmalloc_port()
112 48 1 0x4214fdd0 wmalloc_port()
113 48 1 0x40135b50 wmalloc_port()
114 48 1 0x401359c0 wmalloc_port()
115 48 1 0x40135ab0 wmalloc_port()
116 48 1 0x40135bf0 wmalloc_port()
117 40 5 0x44781250 RT_putInFreeList()
118 32 1 0x44b86390 RT_createList()
119 32 1 0x4011f170 RT_createList()
120 32 1 0x4011f1b0 RT_createList()
121 32 2 0x40364f60 calloc()
122 32 1 0x44b86350 RT_createList()
123 24 1 0x40365110 MSGXX_my_msglib_private_info()
124 24 1 0x403650e0 _nss_files_constr()
125 24 1 0x40365740 _nss_files_constr()
126 20 1 0x40365800 DSS_Manager_create()
127 20 1 0x40365050 wmalloc_port()
128 20 1 0x440244d0 wmalloc_port()
129 18 1 0x44024500 wmalloc_port()
130 16 2 0x44abac60 RT_putInFreeList()
131 15 2 0x42152180 strdup()
132 12 3 0x42151f00 strdup()
133 12 2 0x421521a0 strdup()
134 12 1 0x42151780 wmalloc_port()
135 8 1 0x42151840 RT_createTree()
136 8 1 0x44b623d0 TIMERXX_my_thread_info()
137 8 1 0x44b623f0 RT_createTree()
138 8 1 0x44b62410 RT_createTree()
139 8 1 0x4215bbd0 add_to_list()
140 8 1 0x42151f80 _nss_dns_constr()
141 8 1 0x42161590 add_to_list()
142 8 1 0x44b62430 RT_createTree()
143 8 1 0x42151ae0 RT_createTree()
144 8 1 0x421517c0 RT_createTree()
145 8 1 0x403b0900 TIMERXX_my_thread_info()
146 4 1 0x42161470 create_list()
147 4 1 0x403b0660 __pthread_alloc()
148 4 1 0x44b623b0 TIMERXX_get_my_thread_application()
149 4 1 0x421517a0 TIMERXX_get_my_thread_application()
150 4 1 0x42152000 res_search()
151 4 1 0x421520e0 res_send()
152 4 1 0x4215b530 create_list()
153 4 1 0x4215a820 create_list()


-------------------------------------------------------------------------

Detailed Report

-------------------------------------------------------------------------
32782336 bytes in 512 blocks (61.90% of all bytes allocated)
These range in size from 64028 to 64028 bytes and are allocated
#0 init_buffers() at mod_exp/OCframeworks/export/HP-AIN/OC/oc_malloc.h:145
#1 MSGXX_init_module() at build/OCframeworks/code/MsgLib/msggen.c:221
#2 MSG_init_module() at build/OCframeworks/code/MsgLib/MsgLib.c:203
#3 DSS_Manager_create() at build/OCframeworks/code/DSS_lib/DSS_manager.c:340

-------------------------------------------------------------------------
7111744 bytes in 16400 blocks (13.43% of all bytes allocated)
These range in size from 68 to 756 bytes and are allocated
#0 wmalloc_port() at utils.c:811
#1 walloc() at memory3.c:106
#2 vtaskInitiatePhase2(vTask*,cvops_state*) at init.c:974
#3 initConnVtask() at init.c:1103

-------------------------------------------------------------------------
2361904 bytes in 16424 blocks (4.46% of all bytes allocated)
These range in size from 16 to 32776 bytes and are allocated
#0 wmalloc_port() at utils.c:811
#1 walloc() at memory3.c:106
#2 wzalloc() at memory.c:77
#3 wzcalloc() at memory.c:91

-------------------------------------------------------------------------
2048896 bytes in 32 blocks (3.87% of all bytes allocated)
These range in size from 64028 to 64028 bytes and are allocated
#0 init_buffers() at mod_exp/OCframeworks/export/HP-AIN/OC/oc_malloc.h:145
#1 MSGXX_init_module() at build/OCframeworks/code/MsgLib/msggen.c:221
#2 MSG_init_module() at build/OCframeworks/code/MsgLib/MsgLib.c:203
#3 xxUFT_init() at build/OCframeworks/code/xUFTLib/xxUFTLib.c:108

-------------------------------------------------------------------------
2048896 bytes in 32 blocks (3.87% of all bytes allocated)
These range in size from 64028 to 64028 bytes and are allocated
#0 init_buffers() at mod_exp/OCframeworks/export/HP-AIN/OC/oc_malloc.h:145
#1 MSGXX_init_module() at build/OCframeworks/code/MsgLib/msggen.c:221
#2 MSG_init_module() at build/OCframeworks/code/MsgLib/MsgLib.c:203
#3 UFT_init() at build/OCframeworks/code/UFTLib/src/UFTLib.c:74

-------------------------------------------------------------------------
1968000 bytes in 16400 blocks (3.72% of all bytes allocated)
These range in size from 120 to 120 bytes and are allocated
#0 wmalloc_port() at utils.c:811
#1 walloc() at memory3.c:106
#2 createConnections() at connects.c:315
#3 vtaskInitiatePhase2(vTask*,cvops_state*) at init.c:1009

-------------------------------------------------------------------------
1265664 bytes in 256 blocks (2.39% of all bytes allocated)
These range in size from 4944 to 4944 bytes and are allocated
#0 init_cinfos() at build/OCframeworks/code/MsgLib/msggen.c:454
#1 MSGXX_init_module() at build/OCframeworks/code/MsgLib/msggen.c:226
#2 MSG_init_module() at build/OCframeworks/code/MsgLib/MsgLib.c:203
#3 DSS_Manager_create() at build/OCframeworks/code/DSS_lib/DSS_manager.c:340

-------------------------------------------------------------------------
1024000 bytes in 25600 blocks (1.93% of all bytes allocated)
These range in size from 40 to 40 bytes and are allocated
#0 init_buffers() at build/OCframeworks/code/MsgLib/msggen.c:385
#1 MSGXX_init_module() at build/OCframeworks/code/MsgLib/msggen.c:221
#2 MSG_init_module() at build/OCframeworks/code/MsgLib/MsgLib.c:203
#3 DSS_Manager_create() at build/OCframeworks/code/DSS_lib/DSS_manager.c:340

-------------------------------------------------------------------------
512000 bytes in 12800 blocks (0.97% of all bytes allocated)
These range in size from 40 to 40 bytes and are allocated
#0 init_buffers() at build/OCframeworks/code/MsgLib/msggen.c:385
#1 MSGXX_init_module() at build/OCframeworks/code/MsgLib/msggen.c:221
#2 MSG_init_module() at build/OCframeworks/code/MsgLib/MsgLib.c:203
#3 xxUFT_init() at build/OCframeworks/code/xUFTLib/xxUFTLib.c:108

-------------------------------------------------------------------------
512000 bytes in 12800 blocks (0.97% of all bytes allocated)
These range in size from 40 to 40 bytes and are allocated
#0 init_buffers() at build/OCframeworks/code/MsgLib/msggen.c:385
#1 MSGXX_init_module() at build/OCframeworks/code/MsgLib/msggen.c:221
#2 MSG_init_module() at build/OCframeworks/code/MsgLib/MsgLib.c:203
#3 UFT_init() at build/OCframeworks/code/UFTLib/src/UFTLib.c:74

-------------------------------------------------------------------------
393264 bytes in 8193 blocks (0.74% of all bytes allocated)
These range in size from 48 to 48 bytes and are allocated
#0 wmalloc_port() at utils.c:811
#1 walloc() at memory3.c:106
#2 setVtaskToolStructure() at tool.c:63
#3 mapAsnhomeVtaskInit() from

-------------------------------------------------------------------------
393264 bytes in 8193 blocks (0.74% of all bytes allocated)
These range in size from 48 to 48 bytes and are allocated
#0 wmalloc_port() at utils.c:811
#1 walloc() at memory3.c:106
#2 setVtaskToolStructure() at tool.c:63
#3 giwAsnhomeVtaskInit() from

-------------------------------------------------------------------------
98316 bytes in 8193 blocks (0.19% of all bytes allocated)
These range in size from 12 to 12 bytes and are allocated
#0 wmalloc_port() at utils.c:811
#1 walloc() at memory3.c:106
#2 mapAsnhomeVtaskInit() from
#3 installVtaskToolArgs() at tool.c:156

-------------------------------------------------------------------------
98316 bytes in 8193 blocks (0.19% of all bytes allocated)
These range in size from 12 to 12 bytes and are allocated
#0 wmalloc_port() at utils.c:811
#1 walloc() at memory3.c:106
#2 giwAsnhomeVtaskInit() from
#3 installVtaskToolArgs() at tool.c:156

-------------------------------------------------------------------------
79104 bytes in 16 blocks (0.15% of all bytes allocated)
These range in size from 4944 to 4944 bytes and are allocated
#0 init_cinfos() at build/OCframeworks/code/MsgLib/msggen.c:454
#1 MSGXX_init_module() at build/OCframeworks/code/MsgLib/msggen.c:226
#2 MSG_init_module() at build/OCframeworks/code/MsgLib/MsgLib.c:203
#3 UFT_init() at build/OCframeworks/code/UFTLib/src/UFTLib.c:74

-------------------------------------------------------------------------
79104 bytes in 16 blocks (0.15% of all bytes allocated)
These range in size from 4944 to 4944 bytes and are allocated
#0 init_cinfos() at build/OCframeworks/code/MsgLib/msggen.c:454
#1 MSGXX_init_module() at build/OCframeworks/code/MsgLib/msggen.c:226
#2 MSG_init_module() at build/OCframeworks/code/MsgLib/MsgLib.c:203
#3 xxUFT_init() at build/OCframeworks/code/xUFTLib/xxUFTLib.c:108

-------------------------------------------------------------------------
17324 bytes at 0x42494f70 (0.03% of all bytes allocated)
#0 SLDB_Manager_create() at build/OCframeworks/code/SLDB_lib/SLDB_manager.c:45
#1 SLDB_initWS() at build/OCframeworks/code/SLDB_lib/SLDB_intf.c:149
#2 XXXxUFTctor() at build/OCframeworks/code/xUFTLib/xUFTLib.c:359
#3 xUFT_init() at build/OCframeworks/code/xUFTLib/xUFTLib.c:890

-------------------------------------------------------------------------
14336 bytes in 512 blocks (0.03% of all bytes allocated)
These range in size from 28 to 28 bytes and are allocated
#0 init_buffers() at build/OCframeworks/code/MsgLib/msggen.c:346
#1 MSGXX_init_module() at build/OCframeworks/code/MsgLib/msggen.c:221
#2 MSG_init_module() at build/OCframeworks/code/MsgLib/MsgLib.c:203
#3 DSS_Manager_create() at build/OCframeworks/code/DSS_lib/DSS_manager.c:340

-------------------------------------------------------------------------
12800 bytes in 200 blocks (0.02% of all bytes allocated)
These range in size from 64 to 64 bytes and are allocated
#0 RT_allocateNode() at build/OCframeworks/code/TimerLib/src/RadixTree.c:212
#1 RT_getANodeFromFreeList() at build/OCframeworks/code/TimerLib/src/RadixTree.c:268
#2 RT_createTree() at build/OCframeworks/code/TimerLib/src/RadixTree.c:437
#3 TIMERXX_initRadixTree() at build/OCframeworks/code/TimerLib/src/TimerRadixTree.c:477

-------------------------------------------------------------------------
12420 bytes in 5 blocks (0.02% of all bytes allocated)
These range in size from 2484 to 2484 bytes and are allocated
#0 DSS_Manager_create() at build/OCframeworks/code/DSS_lib/DSS_manager.c:272
#1 DSS_initWS() at build/OCframeworks/code/DSS_lib/DSS_intf.c:91
#2 SLDB_initWS() at build/OCframeworks/code/SLDB_lib/SLDB_intf.c:166
#3 XXXxUFTctor() at build/OCframeworks/code/xUFTLib/xUFTLib.c:359

-------------------------------------------------------------------------
11900 bytes at 0x44761be0 (0.02% of all bytes allocated)
#0 CFGXX_load_file() at build/OCframeworks/code/ConfigLib/src/confwork.c:122
#1 CFG_init() at build/OCframeworks/code/ConfigLib/src/ConfigLib.c:295
#2 OCResourceFmk_open_global_conf() at build/OCframeworks/code/OCResourceFmk/OCResourceFmk.c:313
#3 DSS_Register_getConf() at build/OCframeworks/code/DSS_lib/DSS_register.c:4064

-------------------------------------------------------------------------
10624 bytes at 0x4475f240 (0.02% of all bytes allocated)
#0 CFGXX_load_file() at build/OCframeworks/code/ConfigLib/src/confwork.c:122
#1 CFG_init() at build/OCframeworks/code/ConfigLib/src/ConfigLib.c:295
#2 OCResourceFmk_open() at build/OCframeworks/code/OCResourceFmk/OCResourceFmk.c:111
#3 DSS_Manager_MyGetPath() at build/OCframeworks/code/DSS_lib/DSS_manager.c:127

-------------------------------------------------------------------------
9880 bytes in 65 blocks (0.02% of all bytes allocated)
These range in size from 152 to 152 bytes and are allocated
#0 DSS_Manager_create() at build/OCframeworks/code/DSS_lib/DSS_manager.c:299
#1 DSS_initWS() at build/OCframeworks/code/DSS_lib/DSS_intf.c:91
#2 SLDB_initWS() at build/OCframeworks/code/SLDB_lib/SLDB_intf.c:166
#3 XXXxUFTctor() at build/OCframeworks/code/xUFTLib/xUFTLib.c:359

-------------------------------------------------------------------------
8788 bytes at 0x4249e0b0 (0.02% of all bytes allocated)
#0 MSGXX_init_module() at build/OCframeworks/code/MsgLib/msggen.c:135
#1 MSG_init_module() at build/OCframeworks/code/MsgLib/MsgLib.c:203
#2 DSS_Manager_create() at build/OCframeworks/code/DSS_lib/DSS_manager.c:340
#3 DSS_initWS() at build/OCframeworks/code/DSS_lib/DSS_intf.c:91

-------------------------------------------------------------------------
8788 bytes at 0x4478d690 (0.02% of all bytes allocated)
#0 MSGXX_init_module() at build/OCframeworks/code/MsgLib/msggen.c:135
#1 MSG_init_module() at build/OCframeworks/code/MsgLib/MsgLib.c:203
#2 xxUFT_init() at build/OCframeworks/code/xUFTLib/xxUFTLib.c:108
#3 NewChan() at build/OCframeworks/code/xUFTLib/xUFTLib.c:1282

-------------------------------------------------------------------------
8788 bytes at 0x4216ee80 (0.02% of all bytes allocated)
#0 MSGXX_init_module() at build/OCframeworks/code/MsgLib/msggen.c:135
#1 MSG_init_module() at build/OCframeworks/code/MsgLib/MsgLib.c:203
#2 UFT_init() at build/OCframeworks/code/UFTLib/src/UFTLib.c:74
#3 UFT_blocking_init() at build/OCframeworks/code/UFTLib/src/UFTLib.c:134

-------------------------------------------------------------------------
8208 bytes at 0x44ab6180 (0.02% of all bytes allocated)
#0 _wrtchk() from /usr/lib/hpux32/libc.so.1
#1 printf() from /usr/lib/hpux32/libc.so.1
#2 print_data(message*) from
#3 XgfBody(message*) from

Atul Goel
Frequent Advisor

Re: Heap fragementation on HPUX

Hi Dennis,,

Yes, it is a multi threaded application.
mallocnextgen is not an option for me because it is assocaited with cost :(
Dennis Handly
Acclaimed Contributor

Re: Heap fragementation on HPUX

>Following is the heap profile of one run. Can you figure out something?

You need to do more than one of these to see any differences.

Does this change:
Heap Size = 78169512 bytes
Outstanding Allocations:
52961479 bytes allocated in 136358 blocks

If the Heap Size grows but Outstanding Allocations doesn't, you have heap fragmentation.

From your Detailed Report, you may get some ideas on block sizes:
32782336 bytes in 512 blocks (61.90% of all bytes allocated)
These range in size from 64028 to 64028 bytes

This says all 512 blocks are the same size, 64028. This won't fragment unless you have threads.

7111744 bytes in 16400 blocks (13.43% of all bytes allocated)
These range in size from 68 to 756 bytes and are allocated

This may have problems? Tuning the SBA M_GRAIN may help.

>Yes, it is a multi threaded application.

Then you probably need MallocNextGen.

>mallocnextgen is not an option for me because it is associated with cost :(

That's a strange interpretation of "receive for free".
Or course there may be sysadmin or deployment costs that you didn't mention.
Atul Goel
Frequent Advisor

Re: Heap fragementation on HPUX

I started another trial run with the malloc environment variables as suggested on this post. I set
export _M_ARENA_OPTS=1:2024
export _M_SBA_OPTS=65536:50:256

After this my binary started with an virtual memory size of 130Mb instead of 106 Mb with which it used to start without these parameters.
In my last 36 hour run i have observed an resident size increase of 1248 kb but my virtual memory has not increased even single Mb. Any explanations.
Dennis Handly
Acclaimed Contributor
Solution

Re: Heap fragementation on HPUX

>I have observed an resident size increase of 1248 Kb but my virtual memory has not increased even single Mb.

If your VM hasn't increased, you don't have a leak. The resident size is only an indication of your memory use patterns, nothing to do with the total memory you are using.
Atul Goel
Frequent Advisor

Re: Heap fragementation on HPUX

But why virtual memory of the process increased so much after setting those parameters?
Dennis Handly
Acclaimed Contributor

Re: Heap fragementation on HPUX

>But why virtual memory of the process increased so much after setting those parameters?

Huh? 24 Mb is trivial.
Most likely this is due to the fact that with your SBA parms, every time you allocate <= 64 Kb, if no free block, you get 50 of them. This could mean 50% are wasted. Also every small block is rounded up to 256 byte multiples. This wastes space for very small blocks.
Atul Goel
Frequent Advisor

Re: Heap fragementation on HPUX

Thanks Dennis for all your answers to my basic answers.

Re: Heap fragementation on HPUX

In future please do NOT fill up the thread with such a large amount of data, rather put it in as an attachment!
My house is the bank's, my money the wife's, But my opinions belong to me, not HP!
Atul Goel
Frequent Advisor

Re: Heap fragementation on HPUX

After setting the malloc environment variable the virtual memory became table. Thanks all the experts especially Dennis for their comments
Dennis Handly
Acclaimed Contributor

Re: Heap fragementation on HPUX

>Thanks Dennis for all your answers

If you are real ambitious, you could write a program to take your wdb heap allocation data and "play it back" to model what various values of _M_SBA_OPTS would allocate.

Note: This wouldn't account for patterns like allocating 20 blocks then freeing 10.