[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    It's Qt BUG !! Re: Howto reduce X11 memory usage with several
From:       Achim Spangler <Achim.Spangler () mnet-online ! de>
Date:       2004-06-28 14:58:32
Message-ID: 200406281658.33211.Achim.Spangler () mnet-online ! de
[Download RAW message or body]

Hi,
I tracked down the problem, and found the reason for this strange behaviour 
( sent parallel a bug report to qt-bugs@trolltech.com ).

I tried to control the double buffering with 
QCanvas::setDoubleBuffering( bool ) based on the hide and show events of the 
QCanvasView class ( exactly the derived UMLView class ).

HideEvent -> call QCanvas::setDoubleBuffering( false )
ShowEvent -> call QCanvas::setDoubleBuffering( true )

==> Voila the memory usage is reduced as reported by xrestop:
res-base Wins  GCs Fnts Pxms Misc   Pxm mem  Other   Total   PID Identifier

Without DoubleBuffer Control:
3200000   480  125    5  534  301   330484K     26K 330510K   ?   
MiniVegN.UseCases.xmi - Umbrello UML-Modeller

With DoubleBuffer Control:
3400000   478  110    5  487  192     6504K     23K   6528K   ?   
MiniVegN.UseCases.xmi - Umbrello UML-Modeller

Each time the IDENTIC project file, and all other source code unchanged.

==> Reduction from 330484K  to 6504K

See the attached patch for my workaround to solve this problem.

I think this could be a valuable workaround for other KDE applications which 
use several QCanvas instances - like tabbed browsing for konqueror.

I would be interested in a test with all KDE applications using this for all 
hide/show events of their QCanvas(View).

Bye,
Achim

Am Montag 28 Juni 2004 15:13 schrieb Lubos Lunak:
> On Monday 28 of June 2004 14:04, Achim Spangler wrote:
> > Am Sonntag 27 Juni 2004 15:23 schrieb Lubos Lunak:
> > > Dne čt 24. června 2004 21:48 Achim Spangler napsal(a):
> > > > So I have the following questions:
> > > > 1) What can cause this high memory usage of X11 ( the umbrello
> > > > footprint would be acceptable )?
> > >
> > >  QPixmap's are stored in the XServer. Every pixmap takes roughly
> > > width*height*depth/8 bytes of memory in the XServer.
> >
> > Is there a possibility to tell X11 / Qt that all items on a Canvas should
> > be only displayed with a lower color depth than the X11 desktop has in
> > general - i.e. my screen/ X11 desktop has 24Bit. Thus even simple
> > diagrams which contain mostly QCanvasRectangle ( plain color - no shapes
> > or other effects ) instances can cause a lot of memory usage.
> >
> > I think that there is no way to tell the X11 server / Qt to use some
> > method of compression for hided QCanvas instances - or is there a
> > possibility to do this or comparable?
>
>  X11 pixmaps can have lower depths, QPixmap seems to support only
> monochrome and full depth. But that'd be probably just too much trouble. If
> it's really QCanvas causing this high usage, then QCanvas should get
> optimized. I suggest you ask on qt-bugs@ or some Qt forum.

["DoubleBuffering.patch" (text/x-diff)]

Index: umbrello/umlview.cpp
===================================================================
RCS file: /home/kde/kdesdk/umbrello/umbrello/umlview.cpp,v
retrieving revision 1.145
diff -u -p -r1.145 umlview.cpp
--- umbrello/umlview.cpp	20 Jun 2004 15:18:01 -0000	1.145
+++ umbrello/umlview.cpp	28 Jun 2004 14:54:20 -0000
@@ -89,6 +89,12 @@
 
 #include "toolbarstatefactory.h"
 
+
+// control the manual DoubleBuffering of QCanvas
+// with a define, so that this memory X11 effect can
+// be tested more easily
+#define MANUAL_CONTROL_DOUBLE_BUFFERING
+
 // static members
 const int UMLView::defaultCanvasSize = 1300;
 
@@ -365,6 +371,12 @@ void UMLView::slotToolBarChanged(int c)
 }
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 void UMLView::showEvent(QShowEvent* /*se*/) {
+
+	#ifdef MANUAL_CONTROL_DOUBLE_BUFFERING
+	kdWarning() << "Show Event for " << getName() << endl;
+	canvas()->setDoubleBuffering( true );
+	#endif
+
 	UMLApp* theApp = UMLApp::app();
 	WorkToolBar* tb = theApp->getWorkToolBar();
 	connect(tb,SIGNAL(sigButtonChanged(int)), this, SLOT(slotToolBarChanged(int)));
@@ -381,6 +393,11 @@ void UMLView::hideEvent(QHideEvent* /*he
 	disconnect(tb,SIGNAL(sigButtonChanged(int)), this, SLOT(slotToolBarChanged(int)));
 	disconnect(this,SIGNAL(sigResetToolBar()), tb, SLOT(slotResetToolBar()));
 	disconnect(m_pDoc, SIGNAL(sigObjectCreated(UMLObject *)), this, SLOT(slotObjectCreated(UMLObject *)));
+
+	#ifdef MANUAL_CONTROL_DOUBLE_BUFFERING
+	kdWarning() << "Hide Event for " << getName() << endl;
+	canvas()->setDoubleBuffering( false );
+	#endif
 }
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 UMLListView * UMLView::getListView() {


>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic