Dear all,
There is a misleading matter in the Preconditioner class. That is,
the virtual destructor calls clear(), which is itself a virtual
function that does nothing. In my derived class (let's call it
MyPreconditioner), I am overloading the clear() method to free some
memory that is allocated in MyPreconditioner::init(). However, this
led to a memory leak since calls to virtual member functions in
destructors (likewise in constructors) do *not* call the function of
the derived class. This is an exception of the concept of virtual
functions; it is meant to prevent calls to functions of uninitialized
classes.
I would suggest to remove the clear() function from the class, as in
the attached patch, to avoid this confusion. Actually, I thinkt that
there is really no point in having this clear() method since the only
point in the library where it is called is the destructor, but there
it doesn't have any effect as described above.
What do you think? I would like to hear your feedback before I check
that in.
Best Regards,
Tim
--
Dr. Tim Kroeger
[email protected] Phone +49-421-218-7710
[email protected] Fax +49-421-218-4236
Fraunhofer MEVIS, Institute for Medical Image Computing
Universitaetsallee 29, 28359 Bremen, Germany
Index: include/numerics/preconditioner.h
===================================================================
--- include/numerics/preconditioner.h (Revision 3563)
+++ include/numerics/preconditioner.h (Arbeitskopie)
@@ -90,11 +90,6 @@
virtual void apply(const NumericVector<T> & x, NumericVector<T> & y) = 0;
/**
- * Release all memory and clear data structures.
- */
- virtual void clear () {}
-
- /**
* Initialize data structures if not done so already.
*/
virtual void init () {};
@@ -153,7 +148,6 @@
inline
Preconditioner<T>::~Preconditioner ()
{
- this->clear ();
}
template <typename T>
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Libmesh-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libmesh-devel