User Tools

Site Tools


platform:how_much_memory_does_my_unix_box_have

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

platform:how_much_memory_does_my_unix_box_have [2007/02/02 16:48]
127.0.0.1 external edit
platform:how_much_memory_does_my_unix_box_have [2007/10/30 16:02] (current)
Franz Nelissen
Line 1: Line 1:
 ====== How much memory does my UNIX box have ? ====== ====== How much memory does my UNIX box have ? ======
  
-//How can I find out how much memory I have on my UNIX workstation?// ​ 
  
-This is a tricky question. First of all there are different sorts of +On most machines ​you may use either ​the program ''​top'' ​or ''​free'' ​to obtain ​this information.
-memory. First there is the amount of RAM installed on the machine, +
-then there is the amount of virtual memory available, and the amount +
-of memory a user can get.  +
- +
-First the RAM or real memory. ​On some machine the boot sequence +
-displays how much RAM there is on the system, and for instance on +
-the SUN running SUNOS 4.x one can find out what this was by +
-saying:  +
- +
-     /​etc/​dmesg | grep mem +
- +
-which displays something like:  +
- +
-     mem = 16384K (0x1000000) avail mem = 14938112 +
- +
-Because GAMS and most of the solvers under GAMS access +
-memory rather randomly with the notion of locality this gives you +
-important information:​ solving models that require more workspace +
-than this number will result in lots of disk I/O, and slowing down of +
-the system (trashing). Another way to find this onformation is on the +
-invoice of your computer.  +
- +
-The amount of virtual memory can be interrogated by for instance on +
-a SUN:  +
- +
-     /​etc/​pstat -s +
- +
-which outputs:  +
- +
-     1648k allocated + 468k reserved = 2116 used, 41752k available +
- +
-on a SUN, and for instance for the RS/6000:  +
- +
-     /​etc/​lsps -a +
- +
-which says:  +
-<​code>​ +
-Page Space  Physical Volume ​  ​Volume Group    Size   ​%Used ​ Active ​ Auto  Type +
-hd62        hdisk2 ​           rootvg ​         24MB       ​9 ​    ​yes ​  ​yes ​   lv +
-hd61        hdisk1 ​           rootvg ​         24MB       ​9 ​    ​yes ​  ​yes ​   lv +
-hd6         ​hdisk0 ​           rootvg ​        ​424MB ​      ​2 ​    ​yes ​  ​yes ​   lv +
-</​code>​ +
-The amount of virtual memory should be large than the amount of real +
-memory.  +
- +
-The amount of memory an individual user can get is an other story. Of +
-course the amount of virtual memory is an upperbound, but quota'​s +
-can reduce this further. On AIX for instance smit user allows the +
-super user to change user limits. When running the c-shell (csh) the +
-command limit will display user limits:  +
- +
-        cputime ​       unlimited +
-        filesize ​      ​unlimited +
-        datasize ​      ​524280 kbytes i +
-        stacksize ​     8192 kbytes +
-        coredumpsize ​  ​unlimited +
-        memoryuse ​     unlimited +
-        descriptors ​   64 +
- +
-One other easy way is to write a small c program ​that allocates +
-memory, and tells how much it can allocate:  +
-<​code>​ +
-#include  +
- +
-#define KB  1024 +
-#define MB  (1000*KB) +
- +
-long maxavail(init) +
-long init; +
-+
-     long lo, up, new; +
-     char *p; +
-     long maxdiff; +
- +
-     /* find initial interval */ +
-     lo = 0; +
-     up = init; +
-     while ( (p = malloc(up)) != NULL) { +
-       ​free(p);​ +
-       lo = up; +
-        up = 2*up; +
-     } +
- +
- +
-     /* now reduce interval to acceptable size */ +
-     ​maxdiff = KB; +
- +
-     while ( (up-lo) > maxdiff ) { +
-        new = (up+lo) / 2; +
-        if ( (p = malloc(new)) != NULL) { +
-                free(p); +
-                lo = new; +
-        } +
-        else +
-                up = new; +
-     } +
- +
-     ​return(lo);​ +
-+
- +
-main() { +
- +
-       long avail; +
-        double mb; +
- +
-       avail = maxavail(MB);​ +
-       mb = ((double) avail)/​((double)MB);​ +
-       ​printf("​Could allocate %g MB\n",​mb);​ +
-+
-</​code>​ +
-On some systems this is still an overestimate,​ because until you +
-physically touch all the pages, it is still not sure you can get the +
-memory. On AIX for instance a process may be killed by the +
-operating system, because not enough swap space (virtual memory) +
-was available, when is was really needed. This is sometimes difficult +
-to trace down. AIX offers a version of malloc that really touches all +
-the pages called psmalloc, the source of which can be found in +
-/​usr/​lpp/​bos/​samples/​psmalloc.c.  +
- +
-Notice that on some systems (BSD, AIX 3.1) one extra byte +
-requested can result in a doubling of the memory allocated to your +
-process. On these system memory is allocated using the buddy +
-systems, which uses blocks in sizes of powers of two. This is done +
-to keep the fragmentation of the memory space small. Fragmentation +
-results in many free blocks which are very small, and quite useless, +
-so that a job requesting a big block can not run, while the total of free +
-space would be sufficient.  +
- +
-In GAMS we use dynamic memory inside GAMS itself where we use +
-Pascal's new or C's malloc. Allocation and freeing of memory in very +
-small chunks is on most machines very expensive, therefore we +
-allocate larger blocks, which we manage then ourselves. For the +
-solvers written in C (Cplex, Loqo, XA) malloc is used. Fortran does +
-not have dynamic memory, but most Fortran based solvers under +
-GAMS use the GAMS interface software which provides means to +
-allocate a large array, which then can be partitioned into useful +
-arrays. On many machines ​this is done by a wrapper around malloc. +
-We don't use psmalloc on AIX because it is rather slow.+
  
IMPRESSUM / LEGAL NOTICEPRIVACY POLICY platform/how_much_memory_does_my_unix_box_have.txt · Last modified: 2007/10/30 16:02 by Franz Nelissen