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:
|Plain C||10,568 KB||4,728 KB||.935 MB|
|Mono 1.1.4+||18,912 KB||8,200 KB||4.350 MB|
|Python||15,092 KB||9,164 KB|
|Mono 1.0||31,776 KB||9,916 KB|
|Perl||17,032 KB||10,028 KB|
|Kaffe 1.1.4PRECVS7-1||41,452 KB||11,136 KB||22.000 MB|
|Java HotSpot Client 1.4.2-01||218,612 KB||13,208 KB||174.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.
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:
|C/Gtk+ 1.2||4,716 KB||2,168 KB||.483 MB|
|C/Gtk+ 2.4||10,568 KB||4,728 KB||.935 MB|
|Perl/Gtk 1.2||10,684 KB||5,424 KB||2.208 MB|
|C++/Qt 3.3.3||14,700 KB||6,900 KB||1.360 MB|
|Perl/Gtk 2.4||17,032 KB||10,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