From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fa528,5ecdd5427f39bae4 X-Google-Attributes: gidfa528,public From: Jesper Frank Nemholt Subject: Re: Memory Usage on Tru64 V5.0 Date: 2000/06/29 Message-ID: <395BA539.F5A3A23C@dassic.com> X-Deja-AN: 640519071 Content-Transfer-Encoding: 7bit References: <8jdtlu$20v$1@nnrp1.deja.com> X-Accept-Language: en,pdf Content-Type: text/plain; charset=us-ascii X-Complaints-To: Department of Written Abuse X-Trace: news.inet.tele.dk 962307335 12 195.249.165.89 Organization: Dassic Mime-Version: 1.0 Newsgroups: comp.unix.tru64 Robert_Kerr@byu.edu wrote: > > Hi all, > I have what seems to be a perplexing problem. I have a system with 4 GB > of memory and 10 GB of swap space. I'm running a memory-intensive > application and trying to find out how much memory I'm using. So, I > watch 'top' to see what it says, and here's what it gives me: > Memory: Real: 1270M/4009M act/tot Virtual: 2481M/10057M use/tot Free: > 12M > > It seems to be telling me that it's using 1270M of RAM and 2481M of swap > space. Why doesn't it use all the RAM before dipping into the swap > space? But then I look at the size of my program, and it's at 5281 MB, > which is more than the sum of 1270 + 2481. So, I'm wondering, is 'top' > wrong in its reporting? Is it in fact using all my RAM and some of the > swap, but being reported in some way contrary to what I expect? > Any insights would be wonderful, Here's what I've discovered so far : top and other programs are wrong in some way.... they display the right values but doesn't really know what's going on behind the scenes. Your machine is probably running in eager swap mode. This is the default and makes it allocate swap in advance to make sure there's enough swap space available for the running programs in case they or their data needs to be paged out. This will make it seem like the machine is swapping, and if there's a lot of activity going on it'll seem like it's swapping alot, but in fact it might just be allocating alot of swap space it doesn't use. You can see this with a "swapon -sv" : # swapon -sv Swap partition /dev/vol/rootdg/swapvol (default swap): Allocated space: 131008 pages (1023MB) In-use space: 1 pages ( 0%) Free space: 131007 pages ( 99%) Total swap allocation: Allocated space: 131008 pages (1023MB) Reserved space: 6363 pages ( 4%) In-use space: 1 pages ( 0%) Available space: 124645 pages ( 95%) You can see that 4 percent is reserved, but 0% in actual use. In other words, this machine doesn't swap but has a 4% allocation. To be able to fully see the actual swap need, you can change to lazy swap (set the vm-swap-eager parameter in sysconfigtab to 0) (on 4.0x remove the /sbin/swapdefault link). This will make it use swap only when it needs to, but you don't get the security as with eager swap, where you'll get a failure at program startup if there isn't swap enough. In lazy mode your program will most likely crash when it request more swap (memory) than available. In eager mode they'll usually crash on startup, or if well written, exit nicely with a error message stating that the requested memory couldn't be allocated. The OS will at all time log in messages "Unable to obtain requested swap space" if you hit the limit. On heavy loaded memory poor systems it can often be a good idea to use lazy swap anyway... else you'll get a "Swap space below X%" all the time on both the console and all ptys (I hate the last bit) because stuff like compilers and other memory-hungry-with-a-short-timespan programs make the eager swap allocate all the swap. But on well dimensioned systems, eager swap is usually a "good thing". If you change to lazy swap, the "Reserved space" field will disappear when doing a "swapon -sv". Next thing is the memory usage. Memory you don't use will automagically be used by the OS for cache/buffering. If the system is incative, they'll be small; if not and there's free memory, they'll be large : # vmstat -P Total Physical Memory = 80.00 M = 10240 pages Physical Memory Clusters: start_pfn end_pfn type size_pages / size_bytes 0 256 pal 256 / 2.00M 256 10240 os 9984 / 78.00M Physical Memory Use: start_pfn end_pfn type size_pages / size_bytes 256 280 unixtable 24 / 192.00k 280 287 scavenge 7 / 56.00k 287 901 text 614 / 4.80M 901 1032 data 131 / 1.02M 1032 1194 bss 162 / 1.27M 1195 1366 kdebug 171 / 1.34M 1366 1372 cfgmgmt 6 / 48.00k 1372 1373 locks 1 / 8.00k 1373 1445 unixtable 72 / 576.00k 1445 1466 pmap 21 / 168.00k 1466 1469 logs 3 / 24.00k 1469 1613 vmtables 144 / 1.12M 1613 10240 managed 8627 / 67.40M ============================ Total Physical Memory Use: 9983 / 77.99M Managed Pages Break Down: free pages = 151 active pages = 3782 inactive pages = 2015 wired pages = 2686 ubc pages = 2385 ================== Total = 11019 WIRED Pages Break Down: vm wired pages = 518 ubc wired pages = 686 meta data pages = 99 malloc pages = 840 contig pages = 14 user ptepages = 516 kernel ptepages = 4 free ptepages = 9 ================== Total = 2686 At "Managed Pages Break Down" you can see something called ubc pages. This is the unified buffer cache. This will grow if you have a system with high activity and free memory, thus decreasing the free memory. If some programs need more memory it'll be given to them causing a decrease in the ubc size. So you can to some degree consider a large part of ubc allocated memory to be free for user space code. A big allocater is the filesystem cache : # vmstat -M Memory usage by bucket: bucket# element_size elements_in_use elements_free bytes_in_use fail_nowait 0 16 10950 4410 175200 0 1 32 1785 2055 57120 0 2 64 2521 423 161344 0 3 128 2548 908 326144 0 4 256 258 286 66048 0 5 512 44 20 22528 0 6 1024 9 15 9216 0 7 2048 11 29 22528 0 8 4096 26 4 106496 0 9 8192 33 8 270336 0 10 16384 6 4 98304 0 11 32768 5 0 163840 0 12 65536 3 0 196608 0 13 131072 0 0 0 0 14 262144 0 0 0 0 15 524288 0 0 0 0 16 96 1586 284 152256 0 17 160 1278 507 204480 0 18 192 1099 371 211008 0 19 320 156 219 49920 0 20 384 199 95 76416 0 21 448 164 70 73472 0 22 576 1774 102 1021824 0 23 640 19 5 12160 0 24 704 7 81 4928 0 25 768 159 71 122112 0 26 896 3 15 2688 0 27 1152 885 11 1019520 0 28 1344 310 8 416640 0 29 1600 5 10 8000 0 30 2688 223 23 599424 0 31 12288 10 8 122880 0 Total memory being used from buckets = 5773440 bytes Total free memory in buckets = 1289312 bytes Memory usage by type: Type and Number of bytes being used ADVFS = 1295712 KERNEL TBL = 197184 STREAMS = 1792 AIO = 8192 LAT = 1952 STRHEAD = 2048 ANON = 101136 MBLK = 7424 STRMODSW = 2784 ATM = 70976 MBLKDATA = 21568 STRQUEUE = 5632 CRED = 9600 MIPC = 196768 STRSYNCQ = 2112 DEVBUF = 997344 MOUNT = 2304 SVIPC = 512 DLI = 11648 M_UBC = 12448 TASK = 147840 DMASG = 20864 NCALLOUT = 13312 TEMP = 103664 DQUOT = 12288 NFS = 190224 THREAD = 119808 DYN CONFIG = 15232 NFS REQ = 10240 THREADLOCK = 8320 FIFO = 85504 NXM = 1536 VMANON = 126400 FILE = 24000 PATHNAME = 192 VMENTRY = 150400 FLOCK = 2112 PCB = 89856 VMKANON = 4128 HWINTR = 208 PFILT = 49152 VMLOCK = 768 IFADDR = 2176 PMAP = 40928 VMMAP = 15360 IFM ADDR = 512 ROUTETBL = 2112 VMOBJ = 288512 IFNET = 8208 SEC = 65968 VMSEG = 16320 IO = 36592 SELQ = 7584 VMSWAP = 36992 IPM ADDR = 128 SIGACT = 13504 VMVPAGE = 3520 KALLOC = 30208 SOCKET = 68992 VNODE = 1012096 KERN = 88176 SONAME = 4608 WS = 16384 On my tiny and inactive DEC 2000 AdvFS takes care of 1295712 bytes (about 1 MB). Not much, but I only have 80 MB and little disk activity, and all 80 MB used :( l8r/Jspr