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

List:       kde-core-devel
Subject:    Re: short-lived modeless dialogs (Re: modeless KFileDialog)
From:       Sirtaj Singh Kang <ssk () physics ! unimelb ! EDU ! AU>
Date:       2000-01-28 18:56:24
[Download RAW message or body]

On Thu, Jan 27, 2000 at 05:09:47PM +0100, Waldo Bastian wrote:
> On Thu, 27 Jan 2000, Sirtaj Singh Kang wrote:
> 
> > -> If not, does it actually save memory to delete dialogs that are
> > not in current use?
> 
> It will save _some_ memory but as long as you reuse the dialog it 
> shouldn't kill you. Can you check how much memory a typical dialog 
> takes?

Since you asked I wrote up a QaD function, I'm not sure it's even remotely
accurate but I guess it gives a lower bound:

int memSize( const QObject *obj )
{
	int size = sizeof(*obj);
	const QObjectList *kids = obj->children();

	if ( kids == 0 ) {
		return size;
	}

	for( QObjectListIt iter = *kids; iter.current(); ++iter ) {
		size += memSize( iter.current() );
	}
	return size;
}

On the config dialog of ksensor, a little app I wrote (a basic KDialogBase
with a tab, a listview and a QTextView), this returns 1620 bytes.

With many dialogs like this, I normally start timers etc that may be required
in the constructor with the aim that they will be stopped on dialog deletion.
I'm sure other programmers use this bit of laziness to somewhat reduce their
own code. As a result I have also normally considered CPU and other system
resource usage as a side effect of dialogs lying around unused.

On the original point of deleting dialogs, IMHO the safest way to delete
a dialog, relatively speaking, would be to have it done in the event
queue, which is basically what the timer method does. I imagine a custom
"delete widget" QEvent could be written, I'll look into it.

Or perhaps this is all a big wank and I won't delete any damn dialogs after
all. ;)

-Taj.

Sirtaj S. Kang       taj@kde.org         ssk@physics.unimelb.edu.au
Univ of Melbourne	The "gui" in "Penguin" is pronounced "K-D-E"

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

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