Operating System - HP-UX
1833827 Members
2438 Online
110063 Solutions
New Discussion

using wdb to see processes memory usage

 
jgnuno
New Member

using wdb to see processes memory usage

Hi, i am using wdb to see memory allocated by my c++ processes. The information shown is correctly but i have a problem when deleting memory. After i delete the memory, wdb does not show the memory has been deleted. Probably it is because hp-ux is configured to alloc memory in a "cache way" or something like this...i would like the memory to be liberated whenever i want. Can anyone help me?Thanks
8 REPLIES 8
Steven E. Protter
Exalted Contributor

Re: using wdb to see processes memory usage

Shalom,

Two possibilities spring to mind.

1) Your code is bad and isn't really releasing the memory.
2) wdb has a problem correctly showing this.

Its more than likely not the OS as you surmise. The system should be normally patched with a recent bi-annual patch update.

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
jgnuno
New Member

Re: using wdb to see processes memory usage

Thanks for your answer. I am sure the code is ok because it is just a test with a call to malloc and a call to free...
jgnuno
New Member

Re: using wdb to see processes memory usage

Is there any other way to see the memory used by the process?This would be the way to know if wdb is working properly
Senthil Kumar .A_1
Honored Contributor

Re: using wdb to see processes memory usage

http://hpux.cs.utah.edu/hppd/hpux/Users/dmalloc-5.4.2/

Sk
Let your effort be such, the very words to define it, by a layman - would sound like a "POETRY" ;)
Dennis Handly
Acclaimed Contributor

Re: using wdb to see processes memory usage

When you free memory, it goes back into the heap for later reuse. But not back to the OS.

If you call mallinfo(3), you should see an increase in free blocks.
jgnuno
New Member

Re: using wdb to see processes memory usage

***********Before malloc 1000000 bytes
total space in arena=1178904
number of bytes in free small blocksfsmblks=121248
number of bytes in free ordinary blocks=113824
number of holding blocks=71
number of bytes in holding block headers=4080
cost of enabling keep option=0
number of ordinary blocks=14
number of small blocks=7100
number of bytes in ordinary blocks in use=7100
number of bytes in small blocks in use=864352
***********After malloc 1000000 bytes
total space in arena=2096408
number of bytes in free small blocks=121248
number of bytes in free ordinary blocks=23056
number of holding blocks=71
number of bytes in holding block headers=4080
cost of enabling keep option=0
number of ordinary blocks=16
number of small blocks=7100
number of bytes in ordinary blocks in use=7100
number of bytes in small blocks in use=864352
***********After free 1000000 bytes
total space in arena=2096408
number of bytes in free small blocks=121248
number of bytes in free ordinary blocks=1023088
number of holding blocks=71
number of bytes in holding block headers=4080
cost of enabling keep option=0
number of ordinary blocks=15
number of small blocks smblks=7100
number of bytes in ordinary blocks in use=7100
number of bytes in small blocks in use=864352

You are rigth...de number of in free ordinary blocks are increased. So, the memory is not given to de OS. Can i configure somethig to give this memory to the OS?
jgnuno
New Member

Re: using wdb to see processes memory usage

Interesting enviroment variable MALLOC_TRIM_THRESHOLD
Dennis Handly
Acclaimed Contributor

Re: using wdb to see processes memory usage

>Can I configure something to give this memory to the OS?

Why do you want to do that? Are you short on memory or swap space?

In general, no. There is M_REL_LAST_FBLK for mallopt(3) that may help.

I suppose if you only have one big request, you could use mmap/munmap(2)

(google doesn't find MALLOC_TRIM_THRESHOLD on any HP sites.)

Since this is your first question to the forum, please read the following:
http://forums1.itrc.hp.com/service/forums/helptips.do?#33