By default, Bugzilla does not search the list of RESOLVED bugs.
You can force it to do so by putting the upper-case word ALL in front of your search query, e.g.: ALL tdelibs
We recommend searching for bugs this way, as you may discover that your bug has already been resolved and fixed in a later release.
Bug 2078 - kdesktop_lock leaks Xorg memory
Summary: kdesktop_lock leaks Xorg memory
Status: RESOLVED FIXED
Alias: None
Product: TDE
Classification: Unclassified
Component: tdebase (show other bugs)
Version: 3.5.13.2 [Trinity]
Hardware: amd64 Linux
: P5 major
Assignee: Timothy Pearson
URL:
Depends on:
Blocks:
 
Reported: 2014-07-23 10:46 CDT by Jan Janeček
Modified: 2014-07-31 11:12 CDT (History)
3 users (show)

See Also:
Compiler Version:
TDE Version String:
Application Version:
Application Name:


Attachments
Disable reception of X11 events before sleeping (813 bytes, patch)
2014-07-30 11:15 CDT, Timothy Pearson
Details | Diff
Disable reception of X11 events before sleeping (837 bytes, patch)
2014-07-31 10:07 CDT, Timothy Pearson
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Janeček 2014-07-23 10:46:45 CDT
You can increase X server memory usage just by moving windows around. This only happens when any kdesktop_lock process is running.
I noticed the bug on:
Gentoo with Xorg 1.15.1 and 1.16.0 and Trinity 3.5.13.2, with radeon drivers
Debian with Xorg 1.15.1 and about three months old Trinity nightly build, with nouveau.
I havn't had time to test newest GIT, yet.

It takes some time to reproduce this, because at the beginning, Xorg memory usage increases by bigger jumps after a longer time. But when the memory usage of Xorg starts getting close to 200 Mb, you can literary see the memory usage growing by about 100 Kb per 20 seconds while you constantly move a window.
Comment 1 Timothy Pearson 2014-07-24 12:13:55 CDT
Moving the lock dialog around or moving any other windows around?  Not sure how you could do the latter outside of multiple sessions, but need to ask...

Thanks!
Comment 2 Jan Janeček 2014-07-24 15:41:20 CDT
Moving ANY windows around. When Trinity session starts, it always launches "kdesktop_lock --internal [PID of kdesktop]".
Comment 3 Timothy Pearson 2014-07-24 16:28:17 CDT
OK, so you're seeing this when the kdesktop_lock process is sleeping.  I'll look into it.
Comment 4 Timothy Pearson 2014-07-25 22:07:31 CDT
Are you using compton or kompmgr, or running with no compositor enabled?

I cannot reproduce this on my nVidia test system, but I don't use any compositor.

Thanks!
Comment 5 Jan Janeček 2014-07-26 05:45:33 CDT
From my tests, compositor does not affect it. It just takes very long time to reproduce. On nouveau, the fastest way to reproduce was (for reason unknown to me) enabling WrappedFB in xorg.conf. Then, I was able to reproduce it by moving windows for 10-15 minutes. On radeon, it was a bit harder. I used Xnee to move windows for me and let it run for about 10 hours. Then I checked the machine and could clearly see that any windows movement causes Xorg memory usage to increase by a few KB.
Comment 6 Timothy Pearson 2014-07-27 14:16:03 CDT
(In reply to Jan Janeček from comment #5)
> From my tests, compositor does not affect it. It just takes very long time
> to reproduce. On nouveau, the fastest way to reproduce was (for reason
> unknown to me) enabling WrappedFB in xorg.conf. Then, I was able to
> reproduce it by moving windows for 10-15 minutes. On radeon, it was a bit
> harder. I used Xnee to move windows for me and let it run for about 10
> hours. Then I checked the machine and could clearly see that any windows
> movement causes Xorg memory usage to increase by a few KB.

OK, thanks for that info.  Does locking the session cause the leaked memory to become available, or is it permanently lost even if the session is subsequently locked?

Thanks!
Comment 7 Jan Janeček 2014-07-28 04:57:03 CDT
Locking the session seems to make it even worse:

When I don't move windows much before locking (thus have no leaked Xorg memory), the session locks immediately and everything seems ok.

When Xorg memory usage is increased by moving windows before locking, the session lock dialog takes about 20 seconds to appear - and during that 20 seconds, the Xorg memory usage slowly increases even more!
Comment 8 Timothy Pearson 2014-07-28 10:11:00 CDT
(In reply to Jan Janeček from comment #7)
> Locking the session seems to make it even worse:
> 
> When I don't move windows much before locking (thus have no leaked Xorg
> memory), the session locks immediately and everything seems ok.
> 
> When Xorg memory usage is increased by moving windows before locking, the
> session lock dialog takes about 20 seconds to appear - and during that 20
> seconds, the Xorg memory usage slowly increases even more!

Odd!  I'll probably have to put together a patch to test a theory I have, specifically that unprocessed events accumulate in the X server while the receiver cannot process them due to the receiving process (kdesktop_lock) sleeping.
Comment 9 Timothy Pearson 2014-07-30 11:15:16 CDT
Created attachment 2111 [details]
Disable reception of X11 events before sleeping

Can you try the attached patch for tdebase to see if it resolves the problem?

Thanks!
Comment 10 Jan Janeček 2014-07-30 12:03:45 CDT
Applying the patch to 3.5.13.2 (had to change tqt-->qt) does not solve the problem. (I recompiled just the kdesktop_lock binary, hope that's enough)
Comment 11 Timothy Pearson 2014-07-30 12:51:37 CDT
(In reply to Jan Janeček from comment #10)
> Applying the patch to 3.5.13.2 (had to change tqt-->qt) does not solve the
> problem. (I recompiled just the kdesktop_lock binary, hope that's enough)

Yes, it is sufficient to recompile kdesktop_lock, though you would need to log out / log in for the changed binary to be used.

Strange that this did not work.  I know you mentioned the Xorg memory spiking when you engaged the screen locker; when you unlock the screen does the leaked memory stay or does it disappear?

Thanks!
Comment 12 Jan Janeček 2014-07-30 13:59:30 CDT
In lockprocess.cc in LockProcess constructor, there is:
    XGetWindowAttributes(qt_xdisplay(), RootWindow(qt_xdisplay(), qt_xscreen()), &rootAttr);
    { // trigger creation of QToolTipManager, it does XSelectInput() on the root window
        TQWidget w;
        TQToolTip::add( &w, "foo" );
    }
    XSelectInput( qt_xdisplay(), qt_xrootwin(), SubstructureNotifyMask | rootAttr.your_event_mask );

If I comment out these lines, the problem seems to go away. (Notice the constructor is called in main() by "LockProcess process;" before suspending.)
Comment 13 Timothy Pearson 2014-07-30 22:22:25 CDT
(In reply to Jan Janeček from comment #12)
> In lockprocess.cc in LockProcess constructor, there is:
>     XGetWindowAttributes(qt_xdisplay(), RootWindow(qt_xdisplay(),
> qt_xscreen()), &rootAttr);
>     { // trigger creation of QToolTipManager, it does XSelectInput() on the
> root window
>         TQWidget w;
>         TQToolTip::add( &w, "foo" );
>     }
>     XSelectInput( qt_xdisplay(), qt_xrootwin(), SubstructureNotifyMask |
> rootAttr.your_event_mask );
> 
> If I comment out these lines, the problem seems to go away. (Notice the
> constructor is called in main() by "LockProcess process;" before suspending.)

Doubly strange that my patch did not work then; my patch is targeting the exact same mechanism.  Let me look into this further; I wonder if the X server did not acknowledge my request to disable reception of events.

Tim
Comment 14 Timothy Pearson 2014-07-30 23:13:04 CDT
(In reply to Jan Janeček from comment #12)
> In lockprocess.cc in LockProcess constructor, there is:
>     XGetWindowAttributes(qt_xdisplay(), RootWindow(qt_xdisplay(),
> qt_xscreen()), &rootAttr);
>     { // trigger creation of QToolTipManager, it does XSelectInput() on the
> root window
>         TQWidget w;
>         TQToolTip::add( &w, "foo" );
>     }
>     XSelectInput( qt_xdisplay(), qt_xrootwin(), SubstructureNotifyMask |
> rootAttr.your_event_mask );
> 
> If I comment out these lines, the problem seems to go away. (Notice the
> constructor is called in main() by "LockProcess process;" before suspending.)

Is it sufficient to comment out all lines except for the last XSelectInput, or does it also need to be commented for the bug to be resolved?

Thanks!
Comment 15 Jan Janeček 2014-07-31 05:24:16 CDT
Commenting out XSelectInput was necessary. I tried moving it out of the constructor, and it looks the problem depends on whether it's called before or after app.processEvents(). When I add "app.processEvents();" right before sigsuspend, your patch seems to work.
Comment 16 Timothy Pearson 2014-07-31 10:07:17 CDT
Created attachment 2112 [details]
Disable reception of X11 events before sleeping

(In reply to Jan Janeček from comment #15)
> Commenting out XSelectInput was necessary. I tried moving it out of the
> constructor, and it looks the problem depends on whether it's called before
> or after app.processEvents(). When I add "app.processEvents();" right before
> sigsuspend, your patch seems to work.

OK, I could see that helping.  It seems I'm trying to force TQt3/Xlib to do something it was never really meant to do, so some...unusual calls are required.

So, just to verify, this patch fixes the problem for you?
Comment 17 Jan Janeček 2014-07-31 11:03:24 CDT
Yes, that fixes it.
Comment 18 Timothy Pearson 2014-07-31 11:12:59 CDT
(In reply to Jan Janeček from comment #17)
> Yes, that fixes it.

All right, no adverse effects noted on my test box; pushed to GIT in hash 85afc59.

Thanks for reporting, and for your invaluable help in tracking this down!