Tk Source Code

View Ticket
Login
Ticket UUID: 918052
Title: Memory leak connected to X11, Tk and an XCursor theme
Type: Bug Version: obsolete: 8.4.4
Submitter: pajas Created on: 2004-03-17 14:52:34
Subsystem: 31. Cursor Names Assigned To: jenglish
Priority: 5 Medium Severity:
Status: Closed Last Modified: 2026-10-22 17:22:38
Resolution: Out of Date Closed By: serhiy.storchaka
    Closed on: 2026-09-28 16:07:57
Description:
I'm experiencing memory leaks in Tk-based applications 
(such as demos/widget) running under X11 on SuSE 
Linux 9, XFree86-4.3.0.1-46 and tk-8.4.4-57. I 
discovered it only exhibits in connection with a XCursor 
theme installed in .icons, but apparently not necessarily 
with an arbitrary theme. So far I noticed the problem 
only in connection with a theme called Siver, which can 
be found at 
http://www.kde-look.org/content/show.php?content=5533 
 
The leak appers in the X process, not the Tk applications 
themselves but other toolkits, like Gtk or Qt are not 
affected by this. To reproduce it, install the Silver 
XCursor theme and do the following: 
 
1) run widget demo: /usr/lib/tk8.4/demos/widget  
 
2) run top and press M to sort processes by memory 
usage 
 
3) move mouse pointer over links in the widget main 
window for a while 
(may take some time for the first time, but generally not 
longer than 
a minute - the loger ) 
 
4) watch the X process memory in top. On my setup it 
grows by about 
1MB/5 sec. 
 
Petr
User Comments: serhiy.storchaka added on 2026-09-28 16:07:57:

No longer reproducible with a current X.Org server (Xvfb) and 9.1: after 120000 switches of . configure -cursor watch and . configure -cursor {} with the Adwaita XCursor theme (20000 with Oxygen_White), the X server grows no more than without a theme. As shown by leak.c, the leak was in the X server.


jenglish added on 2005-03-09 02:18:21:
Logged In: YES 
user_id=68433

See also: #1157298

jenglish added on 2004-09-25 05:03:53:
Logged In: YES 
user_id=68433

Confirmed:  while 'leak' is running, the X server process
size grows (seemingly without bounds).  Once the client
exits, though, the X server quickly shrinks back to its
original size according to 'ps -l'.

This is on Debian testing, XFree86 4.3.0, Gnome 2.6 (which
uses an XCursor "cursor theme", but I'm not sure which one.)

dgp added on 2004-09-25 04:24:46:

File Added - 102724: leak.c

dgp added on 2004-09-25 04:24:45:
Logged In: YES 
user_id=80530


Attached is a C program independent
of Tcl and Tk.  Build it with:

   gcc leak.c -o leak -L/usr/X11R6/lib -lX11

(modify as needed for your system), and
then try a run of:

   leak 5000

Watch the X process for leaking memory.
Choose smaller numbers of iterations
for safety to avoid crashing X, then get
larger until you see a leak or are satisfied
this program doesn't have one.

I expect this program to leak, and demonstrate
that the bug here is in the X server, not in Tk.
Perhaps this demo program will be of help
to the X server programmers in fixing their bug.

dgp added on 2004-09-25 00:36:30:
Logged In: YES 
user_id=80530

No, that just a missing initialization
in the debug routine.  committing
fix just for that...

dgp added on 2004-09-24 22:02:45:
Logged In: YES 
user_id=80530


Perhaps related trouble that I can confirm:

$ make runtest
...
% testcursor watch
Segmentation Fault

dgp added on 2004-09-24 05:58:13:
Logged In: YES 
user_id=80530

I can't confirm personally,.but I'm
hearing reports from users that
this leak is present (and hits hard!)
on the default Fedora 2 configuration.

All that's needed to produce the
leak, it seems, is iterations of:

    . configure -cursor watch
    . configure -cursor {}

As noted in earlier comments, the
leak is in the X server process,
not the Tk process.

jenglish added on 2004-04-05 04:43:40:
Logged In: YES 
user_id=68433

More information: X cursor themes are apparently implemented
by the XCursor extension and a corresponding client library
libXcursor.a.  Tk has no direct support for libXcursor (I
didn't even know it existed until today ...); I'd guess that
the problem is *probably* somewhere in the cursor theme,
unless maybe Tk is making assumptions about built-in cursors
that aren't valid in the presence of this extension.

Hard to say much more; there seems to be very little
information on the Web about XCursor.

jenglish added on 2004-04-05 03:45:52:
Logged In: YES 
user_id=68433

Can't easily replicate here.  Any Tk developers who use KDE?

dkf added on 2004-03-18 22:36:47:
Logged In: YES 
user_id=79902

The widget demo main window is just a text widget with a few
trivial (in this aspect) bindings that switch between having
a specified cursor (i.e. non-empty -cursor option) and an
unspecified one.

Classing as a [text] bug, but I suspect the problem is
elsewhere.  Assigning to someone who knows X11 better than I do.

dgp added on 2004-03-18 22:12:11:
Logged In: YES 
user_id=80530

report mentions the widget demos,
so I'll make that the first guess for
the Category.

Attachments: