Font-related X-server bloat with GTK2?



I'm trying to track down a weird X-server memory consumption issue with a GTK2 app that I am working on.

I have an app with an rc file that requests some non-standard fonts. When I export the display of my machine to a different X server, I notice that launching the font consumes a rather large amount of memory in the X server (about 10 MB). It seems to be related to the fact that the destination server doesn't have the fonts installed. While the rc file is being parsed, I get messages to the effect of "Font <font> not found, falling back to Sans..."

The first time the app is launched, these failure messages come fairly slowly, as if the app were attempting to determine which font is the best match for the non-existent one. However, if I kill the app, I regain about 6MB of the X server memory, and then when I launch the app again, the font failures happen instantaneously and I don't see the memory bloat any more until I restart the X server.

I built an instrumented X server and have been able to determine that the first time the app is launched I get about 44 OpenFont/QueryFont X protocol request pairs while the rc file is being parsed. On all subsequent launches, I only get 4 requests instead of 44 -- I assume the X server must have cached the information that the font requested is not available?

So, is this a problem in GTK2 font initialization and handling (probably in Pango) where it's doing a lot of XLoadFont and then forgetting to XFreeFont, or is this likely to be a problem with the X server itself? If it makes any difference, I'm using Tiny X built from the X 4.2.0 source tarballs.

If I remove the rc file so that I am requesting no fonts other than what GTK2 does by default, the memory still goes up by about 3MB with all the default font requests. Then when I kill the app I get 2MB of that back and subsequent launches don't affect the size of X at all. Why this first time hit, and not subsequent times?

The app is supposed to run in a limited memory environment, so I really need to find a way to avoid that first time hit, if possible.

Any thoughts or help appreciated!
--Brett Granger




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]