Operating System - HP-UX
1848854 Members
8731 Online
104038 Solutions
New Discussion

Can we use the top command to found out free mem in the HP-UX system?

 
SOLVED
Go to solution
Vinoyee Madashery Poulo
Frequent Advisor

Can we use the top command to found out free mem in the HP-UX system?

Many times in our carrier we all might have tried to find out the available free memory in the system. Especially, while troubleshooting performance issue. Always the swapinfo, glance and top command outputs will not match and the swapinfo command always says there is sufficient free memory available and enjoy the life! In the same time “top” will be weeping “Available free memory is very less”!!!

Hence, I have spent some time and did some analysis. I have compared the output for swapinfo, glance, top, crashinfo and the system performance memory tab output of sam utility.

With my studies I concluded the following.
1. The free memory statement in the top command output is approximately nearer to the actual free memory and we can consider this output to find out the available free memory in the system.
2. In fully loaded system, in the top command output, real memory +virtual memory+ free memory will be equal to the physical memory size.
Here, the virtual memory is not representing the swap space. The free memory statement in top, sam, glance and crashinfo command outputs are more or less have the same figure.
3. When swapinfo computes the free memory it doesn’t consider the memory allotted for bufpages etc. Hence, it will report available free mem always higher than the actual free mem. The theory says that the physical memory reported in swapinfo is around 70% of the installed memory. However, on all latest systems swapinfo is reporting the actual installed memory.

Conclusion: top is the use full tool to find out the free memory.

Open to comments and additional information on this thread.

# model
9000/800/rp3440
Os: HP-UX 11.23

SAM:

Physical Memory: 18446.5 MB ==18GB
Real Memory:
Active: 6140673.5 KB ===> 6GB
Total: 6183557.0 KB
Virtual Memory:
Active: 10587553.1 KB ==> 10GB
Total: 10696530.1 KB
Free Memory Pages: 31604 at 4 KB/page ==> 129MB
Swap Space:
Avail: 16384 MB
Used: 8934 MB

TOP output :
Memory: 6180956K (6133952K) real, 10 688 884K (10564680K) virtual, 126308K free
Real: 6GB
Virtual: 10GB
Free:126MB


Crashinfo output:
==================
= Memory Globals =
==================

Physical Memory = 4718080 pages (18.00 GB)
Free Memory = 33890 pages (132.38 MB)
Average Free Memory = 35833 pages (139.97 MB)
gpgslim = 17408 pages (68.00 MB)
lotsfree = 73728 pages (288.00 MB)
desfree = 17408 pages (68.00 MB)
minfree = 8448 pages (33.00 MB)


dbc_max_pct = 50 %
dbc_min_pct = 5 %
dbc current pct = 43.8 %
bufpages = 2068766 pages (7.89 GB)
Number of buf headers = 1871625 = (1.7 MB

fixed_cache_size = 0
dbc_parolemem = 0
dbc_stealavg = 356990 (0.34MB
dbc_ceiling = 2359040 pages (9.00 GB)
dbc_nbuf = 117952 (0.11MB
dbc_bufpages = 235904 pages (921.50 MB)
dbc_vhandcredit = 2776543 (2.65MB)
orignbuf = 0
origbufpages = 0 pages

# swapinfo -tam
Mb Mb Mb PCT START/ Mb
TYPE AVAIL USED FREE USED LIMIT RESERVE PRI NAME
dev 16384 27 16357 0% 0 - 1 /dev/vg00/lvol2
reserve - 8963 -8963
memory 18430 5148 13282 28%
total 34814 14138 20676 41% - 0 -
6 REPLIES 6
Jaime Bolanos Rojas.
Honored Contributor

Re: Can we use the top command to found out free mem in the HP-UX system?

Vinoyee,

What I think is happening here, is that you are misunderstanding the output for swapinfo -tam,
the swapinfo output never talks about memory on the system, it only talks about swap, and the memory line only indicates how much pseudo-swap has been reserved, it does not refer in any moment about physical memory.

I think this document will really help on your quest:

ftp://eh:spear9@hprc.external.hp.com/memory.htm

Regards,

Jaime.
Work hard when the need comes out.
Steven E. Protter
Exalted Contributor

Re: Can we use the top command to found out free mem in the HP-UX system?

Shalom,

HP-UX defines memory as ram plus swap.

# swapinfo -tam
Mb Mb Mb PCT START/ Mb
TYPE AVAIL USED FREE USED LIMIT RESERVE PRI NAME
dev 16384 27 16357 0% 0 - 1 /dev/vg00/lvol2
reserve - 8963 -8963
memory 18430 5148 13282 28%
total 34814 14138 20676 41% - 0 -

This output is cleared.
Overall, ram plus swap is a little less than 35 GB. 34814 KB
14 GB 14138 is free.

The two lines above show actual use of memory.

5 GB actually used, almost 9 GB of swap reserved but not actually used (see vmstat or top line of swapinfo output.

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
Vinoyee Madashery Poulo
Frequent Advisor

Re: Can we use the top command to found out free mem in the HP-UX system?

Steven,

My question was that can we use top command output to identify the available free memory in the system. I have compared the top, sam, crashinfo output and sam memory statistics and found that the top free mem statement is the actual free memory in that system. Is my findings are correct?
Don Morris_1
Honored Contributor
Solution

Re: Can we use the top command to found out free mem in the HP-UX system?

Yes, top reports Free memory accurately. (I would expect it is simply reporting the field psd_free from struct pst_dynamic filled in by pstat_getdynamic() -- and since that is a reasonable approximation [being a snapshot, it isn't perfectly accurate by the time the syscall returns usually] of system wide free memory, it is a good value).

As mentioned by others -- swapinfo has nothing to do with free memory, it reports memory *swap* which is not the same thing [and doesn't have to be enabled at all on v2]. It is entirely legal and reasonable for virtual objects to be created, reserve all their virtual address space from disk swap, touch their pages such that free memory is down to 1%... and memory swap will still be untouched (because only disk swap is needed).

Point by point on your studies:

1) Yes, or you could ask pstat directly. Glance or top should both report Free memory correctly. top should not be used to estimate system wide virtual or physical consumption (other than the simplistic Total - Free, which is reasonable) since the rest of top's memory metrics all deal solely with User process memory statistics. The kernel is not represented in top and is usually non-trivial.

2) I would highly doubt it and can easily construct an example where this is not the case. (Take a system with 4Gb of memory and 8Gb of swap, shmmax of 12Gb and do a shmget() for a 10Gb object then shmat() to a process. Don't touch any pages. The process will report (and top will report in the totals) at least 10Gb virtually with no corresponding physical consumption (because the pages aren't touched). This is obviously much greater than total physical... as it should be or why bother doing Virtual Memory, anyway?)

Virtual memory is much more representative of swap space reservation+consumption than physical consumption by default on HP-UX --
virtual objects must by default reserve backing swap. Only use of chatr for Lazy Swap (or specific flags to mmap(2), etc.) will allow virtual objects to be created which do not consume swap.

top, glance and sam should (again) be using the same input for Free memory, so should agree. crashinfo is not a supported command but is a support-only tool. Running it for data on a live system is not something to be encouraged.

3) swapinfo isn't reporting memory at all. See above. Memory swap doesn't have to even exist, much less be sized according to RAM consumption.

And no -- it is also possible to get the converse. If you consider a diskless environment (or at least no disk/FS swap) as a hypothetical [since I'm not sure this is supported anyway], every virtual object would have to reserve from memory swap. Even if no pages were instantiated via fault, memory swap would go to zero -- while free memory could still be unchanged. (Yes, in practice there'd be consumption by metadata -- but the trend would be clear).

I hope this makes it clear that memory swap and free RAM are entirely unrelated in consumption. The one time you can expect them to act in lockstep is in consumption of memory locked pages (mlock / plock or Kernel [implicitly locked]). These by default reserve from memory swap if it is enabled since there's no point in reserving disk swap for unswappable memory. And since these system calls (or kernel allocation paths) almost immediately then also allocate matching RAM, freemem will decrease by the same amount.

My conclusion: pstat is a useful tool to get memory metrics. How you wrap pstat is up to you... top is one way, there are many others.
Vinoyee Madashery Poulo
Frequent Advisor

Re: Can we use the top command to found out free mem in the HP-UX system?

Thank you Don.
Vinoyee Madashery Poulo
Frequent Advisor

Re: Can we use the top command to found out free mem in the HP-UX system?

Thank you one and all who spent time on this query