How to keep X from consuming all available client RAM

Jim Kronebusch jim at
Sun Sep 2 20:03:04 BST 2007

Here is another tip provided by Scott Balnaeves.  If you are having trouble with an
application causing X to consume an overly large amount of RAM (which can result in a
hard freeze of the client) you can use the following to add a variable to lts.conf which
will prevent X from consuming a set limit of RAM.

First add the following to "/opt/ltsp/i386/usr/lib/ltsp/screen.d/ldm" above the last
line in the file that currently reads "exec ldm vt$ttynum :$displaynumexec":


if [ ${XRAMPERC} -lt 100 ]; then
  while read TYPE VALUE UNITS; do
    case ${TYPE} in
          XMEM=$((${XMEM} + ${VALUE}))
  done < /proc/meminfo
  XMEM=$((${XMEM} * ${XRAMPERC} / 100))

  ulimit -v ${XMEM}

Save the file and then modify /opt/i386/ltsp/etc/lts.conf and add the following to your
[Default] section:

# Set maximum percentage of RAM consumed by X

And then save the file.  Set this to the maximum percentage of RAM you ever want X to be
able to consume.  In the example above X will never use more than 95% of total available
memory (this includes RAM and the nbdswap file).  Say in the instance of firefox, upon
access of a website that would use more than 95% of available total system memory,
Firefox will immediately crash (not gracefully either and with no error message).  So
although this isn't pretty, it does keep your client from hard freezing with no other
alternatives than a manual reboot.

Jim Kronebusch
Cotter Tech Department

This message has been scanned for viruses and
dangerous content by the Cotter Technology 
Department, and is believed to be clean.

More information about the edubuntu-users mailing list