Bug 81845 - Sessions are not sharing background's image memory
Summary: Sessions are not sharing background's image memory
Status: RESOLVED FIXED
Alias: None
Product: konsole
Classification: Applications
Component: general (show other bugs)
Version: 1.3.2
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: Konsole Developer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-05-19 06:53 UTC by Guillaume Pratte
Modified: 2008-01-12 21:21 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Guillaume Pratte 2004-05-19 06:53:17 UTC
Version:           1.3.2 (using KDE 3.2.2,  (testing/unstable))
Compiler:          gcc version 3.3.3 (Debian 20040401)
OS:                Linux (i686) release 2.6.4

There is evidence that Konsole is not sharing memory for the background image between the various sessions. For instance, on my system, a xrestop indicates :

res-base Wins  GCs Fnts Pxms Misc   Pxm mem  Other   Total   PID Identifier
3400000    54  126    5   69   72    15992K     10K  16002K   ?   Terminal - Konsole

Adding a new session to Konsole makes the memory go up by about 5 megs :

res-base Wins  GCs Fnts Pxms Misc   Pxm mem  Other   Total   PID Identifier
3400000    57  126    5   68   74    21256K     11K  21267K   ?   Terminal - Konsole

All my sessions are using the same background.. Why should memory usage increase?
Comment 1 Jure Pečar 2004-06-03 02:53:53 UTC
observed same here (yellowdog 3.0, kde 3.2.2 compiled from sources):

xrestop 0.2, konsole with one session:

Pxms Misc   Pxm mem  Other   Total   PID Identifier
109   60     5599K      9K   5609K   ?   pegasus@moonlight:~ - Shell - Konsole

two sessions:
117   62    10690K     10K  10701K   ?   pegasus@moonlight:~ - Shell No. 2 - Konsole

three sessions:
119   64    15779K     10K  15789K   ?   pegasus@moonlight:~ - Shell No. 3 - Konsole

and so on ... 

i have konsole set for transparency with dark background.

Comment 2 Robert Knight 2006-08-07 05:34:46 UTC
Confirmed, Konsole isn't sharing memory for background images between sessions.
Comment 3 Roman Divacky 2007-09-02 10:37:56 UTC
actually this is Qt problem, konsole creates Qt widget for every session and the background assignment is done in Qt. so Qt must be taught to share images. konsole cannot be fixed to support this (at least not easily)
Comment 4 Nigel Stewart 2007-09-05 06:55:43 UTC
Roman, I'm not so sure this problem can be blamed on Qt.  And, I think konsole can be improved in this regard, although it might involve bypassing the use of KRootPixmap.

In konsole.h, there is a container of pixmaps called rootxpms.  Depending on the relevant scheme, a KRootPixmap is attached to each terminal widget to implement the transparency effect.  Internally KRootPixmap is copying the desktop wallpaper image from the X11 server into a KSharedPixmap (inheriting KPixmap inheriting QPixmap).  Then, in KRootPixmap::updateBackground another QPixmap copy is made, with darkening or lightening applied - and passed to the TEWidget.

So, it seems that there is a copy on the server, and two copies per TEWidget.  If there are five terminals using the same scheme, it ought to be possible to reduce this from 10 copies to 2 copies by having one KRootPixmap per scheme, rather than one KRootPixmap per terminal.  However, KRootPixmap is designed to update a particular QWidget rather than a collection, so perhaps an efficient KRootPixmap needs to be forked into the konsole scope.

Please correct me if you find anything incorrect with this analysis.

Nigel
Comment 5 Robert Knight 2007-09-05 14:41:48 UTC
It could definitely be improved in Konsole, in fact there is another bug report with a patch which needs tidying up, testing and committing.  
Comment 6 Roman Divacky 2007-11-04 22:28:25 UTC
sorry for the long delay :(

Nigel, I think your analysis is correct. The problem imho is that 10 terminals (tabs) using the same scheme means that there are 10 copies of the same background pixmap. I see two possible solutions to this problem - either we can teach konsole to use one KRootPixmap per scheme and not per terminal (as you suggest) or we can teach QT how to share backgrounds if they are the same for this given widget.

thnx for looking into this
Comment 7 Robert Knight 2008-01-12 21:21:41 UTC
Konsole/KDE 4 only does translucency via composite, so there is no more usage of KRootPixmap.