Gnome memory use in various languages

Paolo has an interesting post on the memory footprint that Gnome applications incur when using Mono. The following table shows the memory usage, Virtual Memory and Resident Set Size for various runtimes running the same simple Gtk+ based application:

RuntimeVSIZERSSWritable Mapping
Plain C10,568 KB4,728 KB.935 MB
Mono 1.1.4+18,912 KB8,200 KB4.350 MB
Python15,092 KB9,164 KB
Mono 1.031,776 KB9,916 KB
Perl17,032 KB10,028 KB
Kaffe 1.1.4PRECVS7-141,452 KB11,136 KB22.000 MB
Java HotSpot Client 1.4.2-01218,612 KB13,208 KB174.000 MB

The important number to look at is the RSS, the VSIZE is just useful as a reference.

Paolo explores the memory consumption from Mono, as well as a few problems with small libraries.

Update: Paolo provided the numbers for Kaffe and I included his writtable mappings column.

Other observations

Paolo commented a few more things today online.

Gtk+ 2.0 has grown quite a bit (Accessibility, Pango), here is a contrast of Gtk 2.4, 1.2 and Qt. Sorted by RSS:

Runtime/ToolkitVSIZERSSWritable Mapping
C/Gtk+ 1.24,716 KB2,168 KB.483 MB
C/Gtk+ 2.410,568 KB4,728 KB.935 MB
Perl/Gtk 1.210,684 KB5,424 KB2.208 MB
C++/Qt 3.3.314,700 KB6,900 KB1.360 MB
Perl/Gtk 2.417,032 KB10,028 KB

Ahead of Time Compilation

Note that in the numbers above, Mono was running in Just-in-Time compiler mode. One of the things that we have been working on in Mono in the 1.1.x series is improving the produced code for precompiled code. Expect the numbers for our next release to be even closer to C.

The new file format that Zoltan created is designed to maximize the pages that can be shared by using position independent code (PIC). By using PIC code various running Mono applications will share the same pages in memory and only a few pages for each library must be mapped in read-write mode and updated.

This PIC code is typically slower than code that is JIT compiled by Mono. The tradeoff that we are making is that users that run more than one Mono application will benefit by having the Mono applications share more code.

But if performance is more important than memory consumption, users can pass the -O=-aot flag to the Mono runtime. This will disable the use of the Ahead-of-Time compiled code.

The documentation for the new file format lives in mono/docs/aot-compiler.txt

Posted on 09 Feb 2005 by Miguel de Icaza
This is a personal web page. Things said here do not represent the position of my employer.