Terminal Memory Usage

From Mille-Xterm

(Redirected from TerminalMemoryUsage)
Jump to: navigation, search

The main process of a Linux terminal is the X server. All applications run on the application server and the terminal displays them. Terminal shouldn't need a lot of memory, because it display a pixmap on the screen. The amount of memory used sould be fairly stable. What we see in practice is that some applications abuses of the X server memory for caching, rendering and such. This is usualy a good optimization on a fat client, but not on a thin client. This page purpose is to diagnose the problem and solve it.

Contents

Tools for monitoring the memory usage

Example of terminal memory usage
Enlarge
Example of terminal memory usage
Using Ganglia, it is possible to monitor the RAM used on a given terminal. In mille-xterm 1.2, simply add attribute "ENABLE_GMOND" in the configurator, and setup a ganglia server.

The following graph is an example of a typical problem with memory usage. In this case, many documents were open in OpenOffice.org 2.0.2. The memory usage grown from about 15 Mb. When I tried to print a writer document with transparency (5 pages with about 5 images), then the memory usage did a peak. To keep the terminal going, the kernel of killed the X server. On the graphic, we see this huge peak, that loads heavily the terminal.

Tool to get more accuracy on memory usage

For more accuracy, there is the tool in python mem.py that can be used to make graph of X memory usage by each application.

Example of xrestop graph
Enlarge
Example of xrestop graph

Installation

  • Create a xrestop log. You can use this command :
    xrestop -t 1 -b > mem.log
  • Start applications under testing. The log is writtent each second, so take your time otherwise you will not notice memory burst.
  • When the test is over, you can obtain the graphic with this command :
    mem.py mem.log

The threshold is set in order to get rid of unsignificant applications. There is an example on the left of xrestop graph that show tests with OpenOffice.org.

Example of the memory usage with OpenOffice

Experiments for OpenOffice 2.0.2 for X memory usage shows that some settings helps to reduce the amount of RAM used when printing. When printing with transparency, there is a burst of memory used. Two category of settings could help. Transparency setting and graphic resolution.

To determine the impact of those settings, a test file with 5 pages with tranparent graphics was used.

  • Test #1 - Open and close document.
    The test shows that opening a document with graphics doesn't consume much RAM (368 kb).
  • Test #2 - Print with defaut settings.
    The test shows that it took a lot of RAM to print with default settings (19642 kb).
  • Test #3 - Print without transparency.
    The test shows that when disabling transparency, the amount of memory used is 83% less (3154 kb)
  • Test #4 - Print with low resolution (72dpi).
    The test shows that low resolution with transparency took about as much RAM as the defaut resolution with transparency (19726 kb).

When disabling transparency, the alpha is replaced by opaque white. Reducing resolution makes the image with artefact. The conclusion is that the best compromise for Linux terminals are to disable transparency for printing.

Test #1 - Open and close document Test #2 - Print with defaut settings Test #3 - Print without transparency Test #4 - Print with low resolution


Browser memory usage

Firefox memory usage grows anormaly when opening many tabs. This behavior is the same for Konqueror and Mozilla. Setting for max_total_viewer doesn't change this situation. Here are the results.

Test #1 - Firefox with many tabs Test #2 - Opera with many tabs

For the same tabs opened, Firefox uses about 40Mb of ram, as reported by xrestop. The X process is much more, about 150Mb. In contrast, Opera memory usage is low, and stay below 5Mb. This behavior is critical for X11 terminals.

Some settings influence the memory usage for the same opened page, reloaded. This is realy wired : when disabling the memory cache, Firefox uses more X ram. It make no sens, but here are graphs that shows the effect of enabling memory cache.

Test #1 - browser.cache.memory.enable = true Test #2 - browser.cache.memory.enable = false

In the article in Linux Journal of Septembre, it was written to set this setting to "False" but that's completly the oposite.

PDF Viewer memory usage

KPDF use the X server memory for caching. It also render the next page in background (on the ltsp-server). To reduce the caching, go to Settings/Performance and set memory usage to the lower option. To reduce CPU usage on ltsp-server, go to Settings/Performance and disable processor usage like transparency and background rendering.

Personal tools
In other languages