As a user, without administrative privileges, I want to determine if I really can consume a certain amount of memory. Even though "ulimit -a" returned max memory size unlimited, I have an application that seemed limited to 2.1GB, so I wanted to EMPIRICALLY TEST the memory limit.
I welcome other approaches for checking memory limits. The following script does check this 2100MB, with the command line argument $1 as "2200". /usr/bin/bc <<+++ scale=1020000 for (x=1; x<=$1; x++) {z[x]=1/3} +++ if [ $? -eq 0 ] ; then echo "SUCCESSFUL: Consumed \"$1\" megabytes memory (possibly as swap space)." else echo "FAILED: Could not consume \"$1\" megabytes memory." fi You can watch as the memory use increases with something like while : ; do /bin/ps -A -o %cpu,%mem,vsize,rss,cmd | egrep 'RSS|bc'; sleep 1; done With the "bc" calculator set with a "scale" of 1,020,000, each variable set to "1/3" uses 1MB. So to consume 2200MB, we need to create 2200 variables. This worked for "bc -v" GNU version of 1.06 on Linux, but would not work with the limited IBM AIX installed bc which won't even allow "scale=100" (so we installed the GNU version). -- Jameson C. Burt, NJ9L Fairfax, Virginia, USA [EMAIL PROTECTED] http://www.coost.com (202) 690-0380 (work) LTSP.org: magic "mysterious and awe-inspiring even though we know they are real and not supernatural"
signature.asc
Description: Digital signature