[bt-devel] Programming Techniques

Tim Brodie bt-devel@crosswire.org
Fri, 15 Mar 2002 08:54:43 -0500


David White wrote:
> 
> On Thu, 2002-03-14 at 06:37, Holger Schurig wrote:
> > > > AFAIK Qt overloads the new operator, but I'm not sure about this.
> > > > And I never used exceptions, so I can't judge about this :)
> > >
> > > well, using exceptions is A Good Thing. Maybe we should discuss
> > > BibleTime and exceptions sometime in the future :)
> >
> > Maybe the following info can be helpful in deciding if Exceptions are a
> > good thing or not for Qt-Programs.
> >
> > I'm not even sure if your claim that new uses exceptions is true. When
> > you look into the RPM spec files that make qt2 or qt3 you will see the
> > "--disable-g++-exceptions" line. This is a tremendous memory saver for
> > Qt. The switch translates to the -fno-exceptions command line option
> > for gcc (and maybe to other things inside the Qt source code).
> 
> QT may not use exceptions, but that is a completely different thing to
> new not throwing an exception. QT could possibly force new to not throw
> bad_alloc, by changing its definition; however I would suggest that
> enforcing such non-standard behaviour upon users would be A Bad Thing.

There was a long and detailed conversation on the KDE-Devel list a month
or two ago regarding out-of-memory handling within KDE (which is based
on the Qt libraries).  IIRC, the recommendation was not to worry about
it, since:
a) heap exhaustion can be driven by a number of things, including user quota,
b) there was no strategy uncovered within the KDE world to successfully 
	recover from heap exhaustion... once it happens you're effective
	dead in the water.  You can't even present a dialog even if it
	already exists because of transient memory requirements during the
	presentation of the dialog.
c) checking for NULL from new was redundant, as the whole app will 
	terminate on this condition before ever returning to your app.

I could have a faulty memory, so best to check the list archives over
the last couple of months.  It turned out to be a rather vocal 
argument that the moderator killed after a while.  Apparently, memory
management can be a rather religious issue.

--
We do not see things as they are; we see things as we are.

Tim Brodie, IT Manager, Display Works Inc.
90 Milvan Drive, Toronto, Ontario CANADA M9L 1Z6
Phone: 416-740-9677x29 Fax: 416-740-9971 http://www.displayworksinc.com