From 8f0adbc5469a5ce9b08f3eeddf697f081858e579 Mon Sep 17 00:00:00 2001
From: wolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Date: Sun, 26 Nov 2000 21:40:40 +0000
Subject: [PATCH] Implement memory consumption monitors to most classes.

git-svn-id: https://svn.dealii.org/trunk@3502 0785d39b-7218-0410-832d-ea1e28bc413d
---
 deal.II/base/include/base/data_out_base.h     | 207 +++++++--
 deal.II/base/include/base/function.h          |  54 +++
 .../base/include/base/function_derivative.h   | 174 +++----
 deal.II/base/include/base/function_lib.h      |  19 +
 deal.II/base/include/base/logstream.h         |  41 +-
 .../base/include/base/memory_consumption.h    | 423 ++++++++++++++++++
 deal.II/base/include/base/multithread_info.h  |  18 +
 deal.II/base/include/base/parameter_handler.h | 189 ++++++--
 deal.II/base/include/base/quadrature.h        |   8 +
 deal.II/base/include/base/smartpointer.h      |  21 +
 deal.II/base/include/base/tensor.h            |  22 +-
 deal.II/base/include/base/tensor_base.h       |  18 +
 .../source/data_out_base.all_dimensions.cc    |  59 +++
 deal.II/base/source/data_out_base.cc          |  31 +-
 deal.II/base/source/function.cc               |  34 ++
 deal.II/base/source/function_derivative.cc    |  37 +-
 deal.II/base/source/function_lib.cc           |  11 +
 deal.II/base/source/log.cc                    |  19 +
 deal.II/base/source/memory_consumption.cc     |  36 ++
 deal.II/base/source/multithread_info.cc       |   9 +
 deal.II/base/source/parameter_handler.cc      |  91 +++-
 deal.II/base/source/quadrature.cc             |  11 +
 .../deal.II/include/dofs/dof_constraints.h    |   7 +
 deal.II/deal.II/include/dofs/dof_handler.h    |  14 +
 deal.II/deal.II/include/dofs/dof_levels.h     |  21 +
 deal.II/deal.II/include/fe/fe.h               |  13 +
 .../deal.II/include/fe/fe_lib.criss_cross.h   |   7 +-
 deal.II/deal.II/include/fe/fe_system.h        |  15 +-
 deal.II/deal.II/include/fe/fe_values.h        |  23 +
 deal.II/deal.II/include/grid/grid_out.h       |   6 +
 deal.II/deal.II/include/grid/intergrid_map.h  |   7 +
 .../deal.II/include/grid/persistent_tria.h    |   7 +
 deal.II/deal.II/include/grid/tria.h           |  45 +-
 deal.II/deal.II/include/grid/tria_hex.h       |  15 +
 deal.II/deal.II/include/grid/tria_iterator.h  |  24 +-
 deal.II/deal.II/include/grid/tria_levels.h    |  69 ++-
 deal.II/deal.II/include/grid/tria_line.h      |  18 +-
 deal.II/deal.II/include/grid/tria_quad.h      |  15 +
 deal.II/deal.II/source/dofs/dof_handler.cc    |  19 +
 deal.II/deal.II/source/dofs/dof_levels.cc     |  41 ++
 deal.II/deal.II/source/fe/fe.cc               |  23 +
 deal.II/deal.II/source/fe/fe_system.cc        |  21 +
 deal.II/deal.II/source/fe/fe_values.cc        |  55 +++
 .../source/grid/grid_out.all_dimensions.cc    |  12 +-
 deal.II/deal.II/source/grid/intergrid_map.cc  |  13 +-
 .../deal.II/source/grid/persistent_tria.cc    |  13 +
 .../source/grid/tria.all_dimensions.cc        |  86 ++++
 deal.II/deal.II/source/grid/tria.cc           |  22 +
 deal.II/lac/include/lac/block_indices.h       |  17 +
 deal.II/lac/include/lac/block_sparse_matrix.h |   7 +
 .../lac/block_sparse_matrix.templates.h       |  14 +
 .../lac/include/lac/block_sparsity_pattern.h  |   7 +
 deal.II/lac/include/lac/block_vector.h        |   8 +
 .../lac/include/lac/block_vector.templates.h  |  19 +
 deal.II/lac/include/lac/full_matrix.h         |   7 +
 .../lac/include/lac/full_matrix.templates.h   |  10 +
 deal.II/lac/include/lac/precondition_block.h  |   7 +
 .../lac/precondition_block.templates.h        |  17 +
 deal.II/lac/include/lac/sparse_ilu.h          |   7 +
 .../lac/include/lac/sparse_ilu.templates.h    |  10 +
 deal.II/lac/include/lac/sparse_matrix.h       |   7 +
 .../lac/include/lac/sparse_matrix.templates.h |  10 +
 deal.II/lac/include/lac/sparse_vanka.h        |  14 +
 .../lac/include/lac/sparse_vanka.templates.h  |  31 ++
 deal.II/lac/include/lac/sparsity_pattern.h    |   6 +
 deal.II/lac/include/lac/swappable_vector.h    |   7 +
 .../include/lac/swappable_vector.templates.h  |  13 +
 deal.II/lac/include/lac/vector.h              |   7 +
 deal.II/lac/include/lac/vector.templates.h    |  10 +
 deal.II/lac/source/block_sparsity_pattern.cc  |  17 +
 deal.II/lac/source/sparsity_pattern.cc        |   9 +
 71 files changed, 2200 insertions(+), 204 deletions(-)
 create mode 100644 deal.II/base/include/base/memory_consumption.h
 create mode 100644 deal.II/base/source/memory_consumption.cc
 create mode 100644 deal.II/deal.II/source/dofs/dof_levels.cc

diff --git a/deal.II/base/include/base/data_out_base.h b/deal.II/base/include/base/data_out_base.h
index da9b67032f..71ca79938e 100644
--- a/deal.II/base/include/base/data_out_base.h
+++ b/deal.II/base/include/base/data_out_base.h
@@ -418,6 +418,24 @@ class DataOutBase
 					  */
 	Patch ();
 
+					 /**
+					  * Determine an estimate for
+					  * the memory consumption (in
+					  * bytes) of this
+					  * object. Since sometimes
+					  * the size of objects can
+					  * not be determined exactly
+					  * (for example: what is the
+					  * memory consumption of an
+					  * STL @p{map} type with a
+					  * certain number of
+					  * elements?), this is only
+					  * an estimate. however often
+					  * quite close to the true
+					  * value.
+					  */
+	unsigned int memory_consumption () const;
+	
 					 /**
 					  * Exception
 					  */
@@ -471,6 +489,24 @@ class DataOutBase
 					  * all previous contents of this object.
 					  */
 	void parse_parameters (ParameterHandler &prm);
+
+					 /**
+					  * Determine an estimate for
+					  * the memory consumption (in
+					  * bytes) of this
+					  * object. Since sometimes
+					  * the size of objects can
+					  * not be determined exactly
+					  * (for example: what is the
+					  * memory consumption of an
+					  * STL @p{map} type with a
+					  * certain number of
+					  * elements?), this is only
+					  * an estimate. however often
+					  * quite close to the true
+					  * value.
+					  */
+	unsigned int memory_consumption () const;
     };
 
 				     /**
@@ -509,6 +545,24 @@ class DataOutBase
 					  * all previous contents of this object.
 					  */
 	void parse_parameters (ParameterHandler &prm);
+
+					 /**
+					  * Determine an estimate for
+					  * the memory consumption (in
+					  * bytes) of this
+					  * object. Since sometimes
+					  * the size of objects can
+					  * not be determined exactly
+					  * (for example: what is the
+					  * memory consumption of an
+					  * STL @p{map} type with a
+					  * certain number of
+					  * elements?), this is only
+					  * an estimate. however often
+					  * quite close to the true
+					  * value.
+					  */
+	unsigned int memory_consumption () const;
     };
 
     				     /**
@@ -520,39 +574,39 @@ class DataOutBase
 				      */
     struct PovrayFlags 
     {
-                                     /**
-				       * Normal vector interpolation,
-				       * if set to true
-				       *
-				       * default = false
-				       */
-      bool smooth;
-
-                                      /**
-				       * Use bicubic patches (b-splines)
-				       * instead of triangles.
-				       *
-				       * default = false
-				       */
-      bool bicubic_patch;
-
-                                      /**
-				       * include external "data.inc"
-				       * with camera, light and
-				       * texture definition for the
-				       * scene.
-				       *
-				       * default = false
-				       */
-      bool external_data;
-
-                                      /**
-				       * Constructor.
-				       */
-      PovrayFlags (const bool smooth = false,
-		   const bool bicubic_patch = false,
-		   const bool external_data = false);
+					 /**
+					  * Normal vector interpolation,
+					  * if set to true
+					  *
+					  * default = false
+					  */
+	bool smooth;
+	
+					 /**
+					  * Use bicubic patches (b-splines)
+					  * instead of triangles.
+					  *
+					  * default = false
+					  */
+	bool bicubic_patch;
 
+					 /**
+					  * include external "data.inc"
+					  * with camera, light and
+					  * texture definition for the
+					  * scene.
+					  *
+					  * default = false
+					  */
+	bool external_data;
+	
+					 /**
+					  * Constructor.
+					  */
+	PovrayFlags (const bool smooth = false,
+		     const bool bicubic_patch = false,
+		     const bool external_data = false);
+	
 					 /**
 					  * Declare all flags with name
 					  * and type as offered by this
@@ -570,6 +624,24 @@ class DataOutBase
 					  * all previous contents of this object.
 					  */
 	void parse_parameters (ParameterHandler &prm);
+
+					 /**
+					  * Determine an estimate for
+					  * the memory consumption (in
+					  * bytes) of this
+					  * object. Since sometimes
+					  * the size of objects can
+					  * not be determined exactly
+					  * (for example: what is the
+					  * memory consumption of an
+					  * STL @p{map} type with a
+					  * certain number of
+					  * elements?), this is only
+					  * an estimate. however often
+					  * quite close to the true
+					  * value.
+					  */
+	unsigned int memory_consumption () const;
     };
 
 
@@ -847,6 +919,24 @@ class DataOutBase
 					  * all previous contents of this object.
 					  */
 	void parse_parameters (ParameterHandler &prm);
+
+					 /**
+					  * Determine an estimate for
+					  * the memory consumption (in
+					  * bytes) of this
+					  * object. Since sometimes
+					  * the size of objects can
+					  * not be determined exactly
+					  * (for example: what is the
+					  * memory consumption of an
+					  * STL @p{map} type with a
+					  * certain number of
+					  * elements?), this is only
+					  * an estimate. however often
+					  * quite close to the true
+					  * value.
+					  */
+	unsigned int memory_consumption () const;
     };
 
     				     /**
@@ -885,6 +975,24 @@ class DataOutBase
 					  * all previous contents of this object.
 					  */
 	void parse_parameters (ParameterHandler &prm);
+
+					 /**
+					  * Determine an estimate for
+					  * the memory consumption (in
+					  * bytes) of this
+					  * object. Since sometimes
+					  * the size of objects can
+					  * not be determined exactly
+					  * (for example: what is the
+					  * memory consumption of an
+					  * STL @p{map} type with a
+					  * certain number of
+					  * elements?), this is only
+					  * an estimate. however often
+					  * quite close to the true
+					  * value.
+					  */
+	unsigned int memory_consumption () const;
     };
 
 				     /**
@@ -952,6 +1060,23 @@ class DataOutBase
 			   const GmvFlags                     &flags,
 			   ostream                            &out);
 
+				     /**
+				      * Determine an estimate for
+				      * the memory consumption (in
+				      * bytes) of this
+				      * object. Since sometimes
+				      * the size of objects can
+				      * not be determined exactly
+				      * (for example: what is the
+				      * memory consumption of an
+				      * STL @p{map} type with a
+				      * certain number of
+				      * elements?), this is only
+				      * an estimate. however often
+				      * quite close to the true
+				      * value.
+				      */
+    static unsigned int memory_consumption ();
 
 				     /**
 				      * Exception
@@ -1353,6 +1478,24 @@ class DataOutInterface : private DataOutBase
 				      */
     void parse_parameters (ParameterHandler &prm);
     
+				     /**
+				      * Determine an estimate for
+				      * the memory consumption (in
+				      * bytes) of this
+				      * object. Since sometimes
+				      * the size of objects can
+				      * not be determined exactly
+				      * (for example: what is the
+				      * memory consumption of an
+				      * STL @p{map} type with a
+				      * certain number of
+				      * elements?), this is only
+				      * an estimate. however often
+				      * quite close to the true
+				      * value.
+				      */
+    unsigned int memory_consumption () const;
+
 				     /**
 				      * Exception
 				      */
diff --git a/deal.II/base/include/base/function.h b/deal.II/base/include/base/function.h
index 3b5404ec91..69ef98668a 100644
--- a/deal.II/base/include/base/function.h
+++ b/deal.II/base/include/base/function.h
@@ -255,6 +255,24 @@ class Function : public FunctionTime,
 				      */
     virtual void vector_laplacian_list (const vector<Point<dim> > &points,
 					vector<Vector<double> >   &values) const;
+
+				     /**
+				      * Determine an estimate for
+				      * the memory consumption (in
+				      * bytes) of this
+				      * object. Since sometimes
+				      * the size of objects can
+				      * not be determined exactly
+				      * (for example: what is the
+				      * memory consumption of an
+				      * STL @p{map} type with a
+				      * certain number of
+				      * elements?), this is only
+				      * an estimate. however often
+				      * quite close to the true
+				      * value.
+				      */
+    unsigned int memory_consumption () const;
 };
 
 
@@ -455,6 +473,24 @@ class ConstantFunction : public ZeroFunction<dim>
     virtual void vector_value_list (const vector<Point<dim> > &points,
 				    vector<Vector<double> >   &values) const;
 
+				     /**
+				      * Determine an estimate for
+				      * the memory consumption (in
+				      * bytes) of this
+				      * object. Since sometimes
+				      * the size of objects can
+				      * not be determined exactly
+				      * (for example: what is the
+				      * memory consumption of an
+				      * STL @p{map} type with a
+				      * certain number of
+				      * elements?), this is only
+				      * an estimate. however often
+				      * quite close to the true
+				      * value.
+				      */
+    unsigned int memory_consumption () const;
+
   protected:
 				     /**
 				      * Store the constant function value.
@@ -505,6 +541,24 @@ class ComponentSelectFunction : public ConstantFunction<dim>
     virtual void vector_value_list (const vector<Point<dim> > &points,
 				    vector<Vector<double> >   &values) const;
 
+				     /**
+				      * Determine an estimate for
+				      * the memory consumption (in
+				      * bytes) of this
+				      * object. Since sometimes
+				      * the size of objects can
+				      * not be determined exactly
+				      * (for example: what is the
+				      * memory consumption of an
+				      * STL @p{map} type with a
+				      * certain number of
+				      * elements?), this is only
+				      * an estimate. however often
+				      * quite close to the true
+				      * value.
+				      */
+    unsigned int memory_consumption () const;
+
   protected:
     const unsigned int selected;
 };
diff --git a/deal.II/base/include/base/function_derivative.h b/deal.II/base/include/base/function_derivative.h
index 2d0f7aca93..9400f0fff5 100644
--- a/deal.II/base/include/base/function_derivative.h
+++ b/deal.II/base/include/base/function_derivative.h
@@ -16,16 +16,6 @@
 #include <base/exceptions.h>
 #include <base/function.h>
 
-/**
- * Names of difference formulas.
- */
-enum DifferenceFormula
-{
-  Euler,
-  UpwindEuler,
-  FourthOrder
-};
-
 
 /**
  * Derivative of a function object.  The value access functions of
@@ -45,77 +35,105 @@ enum DifferenceFormula
 template <int dim>
 class FunctionDerivative : public Function<dim>
 {
-public:
-				   /**
-				    * Constructor. Provided are the
-				    * function to compute derivatives
-				    * of and the direction vector of
-				    * the differentiation.
-				    */
-  FunctionDerivative (const Function<dim>& f,
-		      const Point<dim>& direction);
+  public:
+				     /**
+				      * Names of difference formulas.
+				      */
+    enum DifferenceFormula
+    {
+	  Euler,
+	  UpwindEuler,
+	  FourthOrder
+    };
 
-				   /**
-				    * Set step size of the difference
-				    * formula. This is set to the
-				    * default in the constructor.
-				    */
-  void set_h (double h_new = 1.e-6);
-  
-				   /**
-				    * Choose the difference formula.
-				    * This is set to the default in
-				    * the constructor.
-				    *
-				    * Formulas implemented right now
-				    * are first order backward Euler
-				    * (@p{UpwindEuler}), second order
-				    * symmetric Euler (@p{Euler}) and
-				    * a symmetric fourth order formula
-				    * (@p{FourthOrder}).
-				    */
-  void set_formula (DifferenceFormula formula = Euler);
-  
-				   /**
-				    * Function value at one point.
-				    */
-  virtual double value (const Point<dim>   &p,
-			const unsigned int  component = 0) const;
-  
-				   /**
-				    * Function values at multiple points.
-				    */
-  virtual void value_list (const vector<Point<dim> > &points,
-			   vector<double>            &values,
-			   const unsigned int         component = 0) const;
 
+				     /**
+				      * Constructor. Provided are the
+				      * function to compute derivatives
+				      * of and the direction vector of
+				      * the differentiation.
+				      */
+    FunctionDerivative (const Function<dim>& f,
+			const Point<dim>& direction);
+    
+				     /**
+				      * Set step size of the difference
+				      * formula. This is set to the
+				      * default in the constructor.
+				      */
+    void set_h (double h_new = 1.e-6);
+    
+				     /**
+				      * Choose the difference formula.
+				      * This is set to the default in
+				      * the constructor.
+				      *
+				      * Formulas implemented right now
+				      * are first order backward Euler
+				      * (@p{UpwindEuler}), second order
+				      * symmetric Euler (@p{Euler}) and
+				      * a symmetric fourth order formula
+				      * (@p{FourthOrder}).
+				      */
+    void set_formula (DifferenceFormula formula = Euler);
+    
+				     /**
+				      * Function value at one point.
+				      */
+    virtual double value (const Point<dim>   &p,
+			  const unsigned int  component = 0) const;
+    
+				     /**
+				      * Function values at multiple points.
+				      */
+    virtual void value_list (const vector<Point<dim> > &points,
+			     vector<double>            &values,
+			     const unsigned int         component = 0) const;    
 
-  DeclException0(ExcInvalidFormula);
-  
-private:
-				   /**
-				    * Function for differentiation.
-				    */
-  const Function<dim>& f;
-				   /**
-				    * Differentiation vector.
-				    */
-  Point<dim> direction;
-  
-				   /**
-				    * Step size of the difference formula.
-				    */
-  double h;
-				   /**
-				    * Difference formula.
-				    */
-  DifferenceFormula formula;
-				   /**
-				    * Helper object. Contains the
-				    * increment vector for the
-				    * formula.
-				    */
-  Point<dim> incr;
+				     /**
+				      * Determine an estimate for
+				      * the memory consumption (in
+				      * bytes) of this
+				      * object. Since sometimes
+				      * the size of objects can
+				      * not be determined exactly
+				      * (for example: what is the
+				      * memory consumption of an
+				      * STL @p{map} type with a
+				      * certain number of
+				      * elements?), this is only
+				      * an estimate. however often
+				      * quite close to the true
+				      * value.
+				      */
+    unsigned int memory_consumption () const;
+    
+    DeclException0(ExcInvalidFormula);
+    
+  private:
+				     /**
+				      * Function for differentiation.
+				      */
+    const Function<dim>& f;
+				     /**
+				      * Differentiation vector.
+				      */
+    Point<dim> direction;
+    
+				     /**
+				      * Step size of the difference formula.
+				      */
+    double h;
+				     /**
+				      * Difference formula.
+				      */
+    DifferenceFormula formula;
+				     /**
+				      * Helper object. Contains the
+				      * increment vector for the
+				      * formula.
+				      */
+    Point<dim> incr;
 };
 
 #endif
diff --git a/deal.II/base/include/base/function_lib.h b/deal.II/base/include/base/function_lib.h
index 299a9beb8c..19f43e7ab0 100644
--- a/deal.II/base/include/base/function_lib.h
+++ b/deal.II/base/include/base/function_lib.h
@@ -406,11 +406,30 @@ class JumpFunction : public Function<dim>
 				 vector<double>            &values,
 				 const unsigned int         component = 0) const;
 
+				     /**
+				      * Determine an estimate for
+				      * the memory consumption (in
+				      * bytes) of this
+				      * object. Since sometimes
+				      * the size of objects can
+				      * not be determined exactly
+				      * (for example: what is the
+				      * memory consumption of an
+				      * STL @p{map} type with a
+				      * certain number of
+				      * elements?), this is only
+				      * an estimate. however often
+				      * quite close to the true
+				      * value.
+				      */
+    unsigned int memory_consumption () const;
+
   protected:
 				     /**
 				      * Advection vector.
 				      */
     const Point<dim> direction;
+
 				     /**
 				      * Steepness (maximal derivative)
 				      * of the slope.
diff --git a/deal.II/base/include/base/logstream.h b/deal.II/base/include/base/logstream.h
index 370d3df0a7..b73a7ed0d1 100644
--- a/deal.II/base/include/base/logstream.h
+++ b/deal.II/base/include/base/logstream.h
@@ -32,15 +32,15 @@
  *
  * The usual usage of this class is through the pregenerated object
  * @p{deallog}. Typical steps are
- * <OL>
- * <LI> @p{deallog.attach(ostream)}: write logging information into a file.
- * <LI> @p{deallog.depth_console(n)}: restrict output on screen to outer loops.
- * <LI> Before entering a new phase of your program, e.g. a new loop,
- * @p{deallog.push("loopname")}.
- * <LI> @p{deallog << anything << endl;} to write logging information
- * (Usage of @p{endl} is mandatory!).
- * <LI> @p{deallog.pop()} when leaving that stage entered with @p{push}.
- * </OL>
+ * @begin{itemize}
+ * @item @p{deallog.attach(ostream)}: write logging information into a file.
+ * @item @p{deallog.depth_console(n)}: restrict output on screen to outer loops.
+ * @item Before entering a new phase of your program, e.g. a new loop,
+ *       @p{deallog.push("loopname")}.
+ * @item @p{deallog << anything << endl;} to write logging information
+ *       (Usage of @p{endl} is mandatory!).
+ * @item @p{deallog.pop()} when leaving that stage entered with @p{push}.
+ * @end{itemize}
  *
  * @author Guido Kanschat, Wolfgang Bangerth, 1999
  */
@@ -213,10 +213,24 @@ class LogStream
 				      */
     LogStream & operator << (void (f)(LogStream &));
 
+
 				     /**
-				      * Declare this function as a friend.
+				      * Determine an estimate for
+				      * the memory consumption (in
+				      * bytes) of this
+				      * object. Since sometimes
+				      * the size of objects can
+				      * not be determined exactly
+				      * (for example: what is the
+				      * memory consumption of an
+				      * STL @p{map} type with a
+				      * certain number of
+				      * elements?), this is only
+				      * an estimate. however often
+				      * quite close to the true
+				      * value.
 				      */
-    friend void endl (LogStream &);
+    unsigned int memory_consumption () const;
 
     				     /**
 				      * Exception
@@ -230,6 +244,11 @@ class LogStream
 				      * the contents of the prefix stack.
 				      */
     void print_line_head();
+
+				     /**
+				      * Declare this function as a friend.
+				      */
+    friend void endl (LogStream &);
 };
 
 
diff --git a/deal.II/base/include/base/memory_consumption.h b/deal.II/base/include/base/memory_consumption.h
new file mode 100644
index 0000000000..2eb08c9d22
--- /dev/null
+++ b/deal.II/base/include/base/memory_consumption.h
@@ -0,0 +1,423 @@
+//----------------------------  memory_consumption.h  ---------------------------
+//    $Id$
+//    Version: $Name$
+//
+//    Copyright (C) 1998, 1999, 2000 by the deal.II authors
+//
+//    This file is subject to QPL and may not be  distributed
+//    without copyright and license information. Please refer
+//    to the file deal.II/doc/license.html for the  text  and
+//    further information on this license.
+//
+//----------------------------  memory_consumption.h  ---------------------------
+#ifndef __deal2__memory_consumption_h
+#define __deal2__memory_consumption_h
+
+
+#include <string>
+#include <vector>
+#include <utility>
+
+
+
+/**
+ * Basic types, vectors of basic types, strings, vectors of composed types 
+ *
+ * @author Wolfgang Bangerth, 2000
+ */
+namespace MemoryConsumption
+{
+				   /**
+				    * Determine the amount of memory
+				    * in bytes consumed by a @p{bool}
+				    * variable.
+				    */
+    inline
+    unsigned int memory_consumption (const bool) 
+    {
+      return sizeof(bool);
+    };
+
+				   /**
+				    * Determine the amount of memory
+				    * in bytes consumed by a @p{char}
+				    * variable.
+				    */
+    inline
+    unsigned int memory_consumption (const char)
+    {
+      return sizeof(char);
+    };
+
+				   /**
+				    * Determine the amount of memory
+				    * in bytes consumed by a
+				    * @p{short int} variable.
+				    */
+    inline
+    unsigned int memory_consumption (const short int) 
+    {
+      return sizeof(short int);
+    };
+  
+
+				   /**
+				    * Determine the amount of memory
+				    * in bytes consumed by a
+				    * @p{short unsigned int} variable.
+				    */
+    inline
+    unsigned int memory_consumption (const short unsigned int) 
+    {
+      return sizeof(short unsigned int);
+    };
+
+
+
+				   /**
+				    * Determine the amount of memory
+				    * in bytes consumed by a @p{int}
+				    * variable.
+				    */
+    inline
+    unsigned int memory_consumption (const int) 
+    {
+      return sizeof(int);
+    };
+  
+
+				   /**
+				    * Determine the amount of memory
+				    * in bytes consumed by a @p{unsigned int}
+				    * variable.
+				    */
+    inline
+    unsigned int memory_consumption (const unsigned int) 
+    {
+      return sizeof(unsigned int);
+    };
+
+
+				   /**
+				    * Determine the amount of memory
+				    * in bytes consumed by a @p{float}
+				    * variable.
+				    */
+    inline
+    unsigned int memory_consumption (const float)
+    {
+      return sizeof(float);
+    };
+
+
+
+				   /**
+				    * Determine the amount of memory
+				    * in bytes consumed by a @p{double}
+				    * variable.
+				    */
+    inline
+    unsigned int memory_consumption (const double)
+    {
+      return sizeof(double);
+    };
+
+				   /**
+				    * Determine an estimate of the
+				    * amount of memory in bytes
+				    * consumed by a @p{string}
+				    * variable.
+				    */
+    unsigned int memory_consumption (const string &s);
+
+				   /**
+				    * Determine an estimate of the
+				    * amount of memory in bytes
+				    * consumed by a @p{vector} of
+				    * certain elements. It does so by
+				    * looping over all elements of the
+				    * vector and determining their
+				    * sizes using the
+				    * @p{memory_consumption}
+				    * functions. If the elements are
+				    * of constant size, there might be
+				    * another global function
+				    * @p{memory_consumption} for this
+				    * data type or if there is a
+				    * member function of that class of
+				    * that names that returns a
+				    * constant value and the compiler
+				    * will unroll this loop so that
+				    * the operation is fast. If the
+				    * size of the data elements is
+				    * variable, for example if they do
+				    * memory allocation themselves,
+				    * then the operation will
+				    * necessarily be more expensive.
+				    *
+				    * Using the algorithm, in
+				    * particular the loop over all
+				    * elements, it is possible to also
+				    * compute the memory consumption
+				    * of vectors of vectors, vectors
+				    * of strings, etc, where the
+				    * individual elements may have
+				    * vastly different sizes.
+				    *
+				    * Note that this algorithm also
+				    * takes into account the size of
+				    * elements that are allocated by
+				    * this vector but not currently
+				    * used.
+				    *
+				    * For the most commonly used
+				    * vectors, there are special
+				    * functions that compute the size
+				    * without a loop. This also
+				    * applies for the special case of
+				    * vectors of bools.
+				    */
+    template <typename T>
+      unsigned int memory_consumption (const vector<T> &v)
+      {
+	unsigned int mem = sizeof(vector<T>);
+	const unsigned int n = v.size();
+	for (unsigned int i=0; i<n; ++i)
+	  mem += memory_consumption(v[i]);
+	mem += (v.capacity() - n)*sizeof(T);
+	return mem;
+      };
+
+
+
+				     /**
+				      * Estimate the amount of memory
+				      * (in bytes) occupied by a
+				      * C-style array. Since in this
+				      * library we do not usually
+				      * store simple data elements
+				      * like @p{double}s in such
+				      * arrays (but rather use STL
+				      * @p{vector}s or deal.II
+				      * @p{Vector} objects), we do not
+				      * provide specializations like
+				      * for the @p{vector} arrays, but
+				      * always use the loop over all
+				      * elements.
+				      */
+    template <typename T, int N>
+      unsigned int memory_consumption (const T (&v)[N])
+      {
+	unsigned int mem = 0;
+	for (unsigned int i=0; i<N; ++i)
+	  mem += memory_consumption(v[i]);
+	return mem;
+      };
+
+
+				     /**
+				      * Specialization of the
+				      * determination of the memory
+				      * consumption of a vector, here
+				      * for a vector of @p{bool}s.
+				      *
+				      * This is a special case, as the
+				      * bools are not stored
+				      * one-by-one, but as a bit
+				      * field.
+				      */
+    inline
+      unsigned int memory_consumption (const vector<bool> &v)
+      {
+	return v.capacity() / 8 + sizeof(v);
+      };
+
+    
+				     /**
+				      * Specialization of the
+				      * determination of the memory
+				      * consumption of a vector, here
+				      * for a vector of @p{int}s.
+				      */
+    inline
+      unsigned int memory_consumption (const vector<int> &v)
+      {
+	return (v.capacity() * sizeof(int) +
+		sizeof(v));
+      };
+    
+    
+				     /**
+				      * Specialization of the
+				      * determination of the memory
+				      * consumption of a vector, here
+				      * for a vector of @p{double}s.
+				      */
+    inline
+      unsigned int memory_consumption (const vector<double> &v)
+      {
+	return (v.capacity() * sizeof(double) +
+		sizeof(v));
+      };
+    
+    
+				     /**
+				      * Specialization of the
+				      * determination of the memory
+				      * consumption of a vector, here
+				      * for a vector of @p{float}s.
+				      */
+    inline
+      unsigned int memory_consumption (const vector<float> &v)
+      {
+	return (v.capacity() * sizeof(float) +
+		sizeof(v));
+      };
+    
+    
+				     /**
+				      * Specialization of the
+				      * determination of the memory
+				      * consumption of a vector, here
+				      * for a vector of @p{char}s.
+				      */
+    inline
+      unsigned int memory_consumption (const vector<char> &v)
+      {
+	return (v.capacity() * sizeof(char) +
+		sizeof(v));
+      };
+    
+
+    
+				     /**
+				      * Specialization of the
+				      * determination of the memory
+				      * consumption of a vector, here
+				      * for a vector of @p{unsigned char}s.
+				      */
+    inline
+      unsigned int memory_consumption (const vector<unsigned char> &v)
+      {
+	return (v.capacity() * sizeof(unsigned char) +
+		sizeof(v));
+      };
+
+
+
+    
+				     /**
+				      * Specialization of the
+				      * determination of the memory
+				      * consumption of a vector, here
+				      * for a vector of pointers.
+				      */
+    template <typename T>
+    inline
+      unsigned int memory_consumption (const vector<T *> &v)
+      {
+	return (v.capacity() * sizeof(T *) +
+		sizeof(v));
+      };
+    
+
+				     /**
+				      * Determine an estimate of the
+				      * amount of memory in bytes
+				      * consumed by a pair of values.
+				      */
+    template <typename A, typename B>
+      inline
+      unsigned int memory_consumption (const pair<A,B> &p)
+      {
+	return (memory_consumption(p.first) +
+		memory_consumption(p.second));
+      };
+    
+				     /**
+				      * Return the amount of memory
+				      * used by a pointer. Make sure
+				      * that you are really interested
+				      * in this, and not the amount of
+				      * memory required by the object
+				      * pointed to.
+				      */
+    template <typename T>
+      inline
+      unsigned int
+      memory_consumption (const T * const)
+      {
+	return sizeof(T*);
+      };
+
+
+
+				     /**
+				      * Return the amount of memory
+				      * used by a pointer. Make sure
+				      * that you are really interested
+				      * in this, and not the amount of
+				      * memory required by the object
+				      * pointed to.
+				      *
+				      * This function is the same as
+				      * above, but for non-const
+				      * pointers
+				      */
+    template <typename T>
+      inline
+      unsigned int
+      memory_consumption (T * const)
+      {
+	return sizeof(T*);
+      };
+
+
+
+				     /**
+				      * Return the amount of memory
+				      * used by a void pointer. Make
+				      * sure that you are really
+				      * interested in this, and not
+				      * the amount of memory required
+				      * by the object pointed to.
+				      *
+				      * Note that we needed this
+				      * function since @p{void} is no
+				      * type and a @p{void*} is thus
+				      * not caught by the general
+				      * @p{T*} template function
+				      * above.
+				      */
+    inline
+      unsigned int
+      memory_consumption (void * const)
+      {
+	return sizeof(void*);
+      };
+    
+    
+				     /**
+				      * For all other types which are
+				      * not explicitely listed: try if
+				      * there is a member function
+				      * called
+				      * @p{memory_consumption}. If
+				      * this is not the case, then the
+				      * compiler will in any case
+				      * complain that this last exit
+				      * does not work.
+				      */
+    template <typename T>
+      inline
+      unsigned int
+      memory_consumption (const T &t)
+      {
+	return t.memory_consumption();
+      };
+}
+
+
+
+#endif
+
diff --git a/deal.II/base/include/base/multithread_info.h b/deal.II/base/include/base/multithread_info.h
index c9f5a54d06..e2f277d5ef 100644
--- a/deal.II/base/include/base/multithread_info.h
+++ b/deal.II/base/include/base/multithread_info.h
@@ -65,6 +65,24 @@ class MultithreadInfo
 				      */
     unsigned int n_default_threads;
 
+				     /**
+				      * Determine an estimate for
+				      * the memory consumption (in
+				      * bytes) of this
+				      * object. Since sometimes
+				      * the size of objects can
+				      * not be determined exactly
+				      * (for example: what is the
+				      * memory consumption of an
+				      * STL @p{map} type with a
+				      * certain number of
+				      * elements?), this is only
+				      * an estimate. however often
+				      * quite close to the true
+				      * value.
+				      */
+    static unsigned int memory_consumption ();
+
 				     /**
 				      * Exception
 				      */
diff --git a/deal.II/base/include/base/parameter_handler.h b/deal.II/base/include/base/parameter_handler.h
index a17c5291fd..c58c12948c 100644
--- a/deal.II/base/include/base/parameter_handler.h
+++ b/deal.II/base/include/base/parameter_handler.h
@@ -86,6 +86,45 @@ namespace Patterns
 					  * this function.
 					  */
 	virtual PatternBase * clone () const = 0;
+
+					 /**
+					  * Determine an estimate for
+					  * the memory consumption (in
+					  * bytes) of this object. To
+					  * avoid unnecessary
+					  * overhead, we do not force
+					  * derivd classes to provide
+					  * this function as a virtual
+					  * overloaded one, but rather
+					  * try to cast the present
+					  * object to one of the known
+					  * derived classes and if
+					  * that fails then take the
+					  * size of this base class
+					  * instead and add 32 byte
+					  * (this value is arbitrary,
+					  * it should account for
+					  * virtual function tables,
+					  * and some possible data
+					  * elements). Since there are
+					  * usually not many thousands
+					  * of objects of this type
+					  * around, and since the
+					  * @p{memory_consumption}
+					  * mechanism is used to find
+					  * out where memory in the
+					  * range of many megabytes
+					  * is, this seems like a
+					  * reasonable approximation.
+					  *
+					  * On the other hand, if you
+					  * know that your class
+					  * deviates from this
+					  * assumption significantly,
+					  * you can still overload
+					  * this function.
+					  */
+	virtual unsigned int memory_consumption () const;
     };
     
 				     /**
@@ -361,6 +400,13 @@ namespace Patterns
 					  */
 	virtual PatternBase * clone () const;
 
+					 /**
+					  * Determine an estimate for
+					  * the memory consumption (in
+					  * bytes) of this object.
+					  */
+	unsigned int memory_consumption () const;
+
       private:
 					 /**
 					  * List of valid strings as
@@ -434,6 +480,13 @@ namespace Patterns
 					  */
 	virtual PatternBase * clone () const;
 
+					 /**
+					  * Determine an estimate for
+					  * the memory consumption (in
+					  * bytes) of this object.
+					  */
+	unsigned int memory_consumption () const;
+
 					 /**
 					  * Exception.
 					  */
@@ -1007,7 +1060,7 @@ class ParameterHandler
 				      * Return status of this object:
 				      * @p{true}=clean or @p{false}=error occured.
 				      */
-    bool ok() const;
+    bool ok () const;
 
 				     /**
 				      * clear status bit and contents.
@@ -1107,14 +1160,22 @@ class ParameterHandler
 				    */
     void log_parameters (LogStream& out);
 
-				   /**
-				    * Log parameters in
-				    * subsection. The subsection is
-				    * determined by the
-				    * @p{subsection_path} member *
-				    * variable.
-				    */
-  void log_parameters_section (LogStream& out);
+				     /**
+				      * Log parameters in
+				      * subsection. The subsection is
+				      * determined by the
+				      * @p{subsection_path} member *
+				      * variable.
+				      */
+    void log_parameters_section (LogStream& out);    
+
+				     /**
+				      * Determine an estimate for
+				      * the memory consumption (in
+				      * bytes) of this
+				      * object.
+				      */
+    unsigned int memory_consumption () const;
 
 				     /**
 				      * Exception
@@ -1158,55 +1219,85 @@ class ParameterHandler
 				      * entry content and regexp, and
 				      * list of subsections.
 				      */
-    struct Section {
+    struct Section 
+    {
 	~Section ();
 
 	typedef map<string, pair<string,Patterns::PatternBase*> > EntryType;
 	
 	EntryType             entries;
 	map<string, Section*> subsections;
+
+					 /**
+					  * Determine an estimate for
+					  * the memory consumption (in
+					  * bytes) of this
+					  * object. Since sometimes
+					  * the size of objects can
+					  * not be determined exactly
+					  * (for example: what is the
+					  * memory consumption of an
+					  * STL @p{map} type with a
+					  * certain number of
+					  * elements?), this is only
+					  * an estimate. however often
+					  * quite close to the true
+					  * value.
+					  */
+	unsigned int memory_consumption () const;
     };
 
 				     /**
-				      * Path of presently selected subsections;
-				      * empty list means top level
+				      * Path of presently selected
+				      * subsections; empty list means
+				      * top level
 				      */
     vector<string> subsection_path;
 
 				     /**
-				      * List of default values organized as a
-				      * tree of subsections
+				      * List of default values
+				      * organized as a tree of
+				      * subsections
 				      */
     Section defaults;
     
 				     /**
-				      * Analogue list of changed entries. The
-				      * tree of subsections is there even if there
-				      * are no changed entry values in a
-				      * subsection; therefore @p{enter_subsection}
-				      * has to create the tree in both @p{Defaults}
-				      * and @p{changed_entries}.
+				      * Analogue list of changed
+				      * entries. The tree of
+				      * subsections is there even if
+				      * there are no changed entry
+				      * values in a subsection;
+				      * therefore @p{enter_subsection}
+				      * has to create the tree in both
+				      * @p{Defaults} and
+				      * @p{changed_entries}.
 				      */
     Section changed_entries;
 
 				     /**
 				      * Scan one line of input.
-				      * @p{lineno} is the number of the line presently
-				      * scanned (for the logs if there are messages).
-				      * @return @p{false} if line contained stuff
-				      * that could not be understood, the uppermost
-				      * subsection was to be left by an @p{END} or
-				      * @p{end} statement, a value for a non-declared
-				      * entry was given or teh entry value did not
-				      * match the regular expression. @p{true}
-				      * otherwise
+				      * @p{lineno} is the number of
+				      * the line presently scanned
+				      * (for the logs if there are
+				      * messages).  @return @p{false}
+				      * if line contained stuff that
+				      * could not be understood, the
+				      * uppermost subsection was to be
+				      * left by an @p{END} or @p{end}
+				      * statement, a value for a
+				      * non-declared entry was given
+				      * or teh entry value did not
+				      * match the regular
+				      * expression. @p{true} otherwise
 				      */
     bool scan_line (string line, const unsigned int lineno);
 
 				     /**
-				      * Get a pointer to the @p{Section} structure
-				      * in the @p{Defaults} tree
-				      * for the subsection we are presently in.
+				      * Get a pointer to the
+				      * @p{Section} structure in the
+				      * @p{Defaults} tree for the
+				      * subsection we are presently
+				      * in.
 				      */
     Section*       get_present_defaults_subsection ();
     
@@ -1231,6 +1322,7 @@ class ParameterHandler
 };
 
 
+
 /**
  *   The class @p{MultipleParameterLoop} offers an easy possibility to test several
  *   parameter sets during one run of the program. For this it uses the
@@ -1455,7 +1547,8 @@ class MultipleParameterLoop : public ParameterHandler
 				      * This is the class the helper class or the
 				      * problem class has to be derived of.
 				      */
-    class UserClass {
+    class UserClass 
+    {
       public:
 					 /**
 					  * @p{create_new} must provide a clean
@@ -1515,13 +1608,24 @@ class MultipleParameterLoop : public ParameterHandler
 				      */
     void loop (UserClass &uc);
 
+				     /**
+				      * Determine an estimate for
+				      * the memory consumption (in
+				      * bytes) of this
+				      * object.
+				      */
+    unsigned int memory_consumption () const;
+
   private:
 				     /**
-				      *	Declare what a multiple entry is: a variant
-				      *	entry (in curly braces @p{{}}) or an
-				      * array (in double curly braces @p{{{}}}).
+				      * Declare what a multiple entry
+				      * is: a variant * entry (in
+				      * curly braces @p{{}}) or an
+				      * array (in double curly braces
+				      * @p{{{}}}).
 				      */
-    enum MultipleEntryType {
+    enum MultipleEntryType 
+    {
 	  variant, array
     };
 
@@ -1529,7 +1633,8 @@ class MultipleParameterLoop : public ParameterHandler
 				      * An object in the list of entries with
 				      * multiple values.
 				      */
-    class Entry {
+    class Entry 
+    {
       public:
 					 /**
 					  * Constructor
@@ -1577,6 +1682,14 @@ class MultipleParameterLoop : public ParameterHandler
 					  * entry or an array.
 					  */
 	MultipleEntryType      type;
+
+					 /**
+					  * Determine an estimate for
+					  * the memory consumption (in
+					  * bytes) of this
+					  * object.
+					  */
+	unsigned int memory_consumption () const;
     };
 
 				     /**
diff --git a/deal.II/base/include/base/quadrature.h b/deal.II/base/include/base/quadrature.h
index ddfd70c2a2..b786abf8c1 100644
--- a/deal.II/base/include/base/quadrature.h
+++ b/deal.II/base/include/base/quadrature.h
@@ -125,6 +125,14 @@ class Quadrature : public Subscriptor
 				      */
     const vector<double> & get_weights () const;
 
+    				     /**
+				      * Determine an estimate for
+				      * the memory consumption (in
+				      * bytes) of this
+				      * object.
+				      */
+    unsigned int memory_consumption () const;
+
   protected:
 				     /**
 				      * List of quadrature points. To be filled
diff --git a/deal.II/base/include/base/smartpointer.h b/deal.II/base/include/base/smartpointer.h
index 7a810d08c0..a87be47f23 100644
--- a/deal.II/base/include/base/smartpointer.h
+++ b/deal.II/base/include/base/smartpointer.h
@@ -154,6 +154,17 @@ class SmartPointer
 				      * variable which we are given.
 				      */
     void swap (T *&tt);
+
+				     /**
+				      * Return an estimate of the
+				      * amount of memory (in bytes)
+				      * used by this class. Note in
+				      * particular, that this only
+				      * includes the amount of memory
+				      * used by @it{this} object, not
+				      * by the object pointed to.
+				      */
+    unsigned int memory_consumption () const;
     
   private:
 				     /**
@@ -295,6 +306,16 @@ void SmartPointer<T>::swap (T *&tt)
 
 
 
+template <typename T>
+inline
+unsigned int SmartPointer<T>::memory_consumption () const
+{
+  return sizeof(SmartPointer<T>);
+};
+
+
+
+
 /**
  * Global function to swap the contents of two smart pointers. As both
  * objects to which the pointers point retain to be subscribed to, we
diff --git a/deal.II/base/include/base/tensor.h b/deal.II/base/include/base/tensor.h
index 98e6576fb7..750bfc1b0a 100644
--- a/deal.II/base/include/base/tensor.h
+++ b/deal.II/base/include/base/tensor.h
@@ -162,6 +162,14 @@ class Tensor
 				      */
     void clear ();
 
+				     /**
+				      * Determine an estimate for
+				      * the memory consumption (in
+				      * bytes) of this
+				      * object.
+				      */
+    static unsigned int memory_consumption ();
+
 // 				     /**
 // 				      * Exception
 // 				      */
@@ -196,9 +204,7 @@ class Tensor
 
 
 /*--------------------------- Inline functions -----------------------------*/
-// in the following, declarations of operators look rather weird because they are
-// split over several lines. this is necessary, however, because otherwise doc++
-// gets really confused about this all... :-(
+
 
 
 template <int rank_, int dim>
@@ -368,6 +374,16 @@ void Tensor<rank_,dim>::clear ()
 };
 
 
+
+template <int rank_, int dim>
+inline
+unsigned int
+Tensor<rank_,dim>::memory_consumption ()
+{
+  return sizeof(Tensor<rank_,dim>);
+};
+
+
 /* ----------------- Non-member functions operating on tensors. ------------ */
 
 
diff --git a/deal.II/base/include/base/tensor_base.h b/deal.II/base/include/base/tensor_base.h
index 123f16d6a2..8eb3d210c8 100644
--- a/deal.II/base/include/base/tensor_base.h
+++ b/deal.II/base/include/base/tensor_base.h
@@ -213,6 +213,14 @@ class Tensor<1,dim>
 				      */
     void unroll (Vector<double> &result) const;
 
+				     /**
+				      * Determine an estimate for
+				      * the memory consumption (in
+				      * bytes) of this
+				      * object.
+				      */
+    static unsigned int memory_consumption ();
+
   protected:
 				     /**
 				      * Help function for unroll.
@@ -452,6 +460,16 @@ void Tensor<1,dim>::clear ()
 
 
 
+template <int dim>
+inline
+unsigned int
+Tensor<1,dim>::memory_consumption ()
+{
+  return sizeof(Tensor<1,dim>);
+};
+
+
+
 /**
  * Output operator for tensors of rank 1. Print the elements
  * consecutively, with a space in between.
diff --git a/deal.II/base/source/data_out_base.all_dimensions.cc b/deal.II/base/source/data_out_base.all_dimensions.cc
index 2fcad5f315..d6dc2f4d65 100644
--- a/deal.II/base/source/data_out_base.all_dimensions.cc
+++ b/deal.II/base/source/data_out_base.all_dimensions.cc
@@ -14,6 +14,7 @@
 
 #include <base/data_out_base.h>
 #include <base/parameter_handler.h>
+#include <base/memory_consumption.h>
 
 
 DataOutBase::UcdFlags::UcdFlags (const bool write_preamble) :
@@ -45,6 +46,15 @@ void DataOutBase::UcdFlags::parse_parameters (ParameterHandler &prm)
 };
 
 
+unsigned int
+DataOutBase::UcdFlags::memory_consumption () const
+{
+				   // only simple data elements, so
+				   // use sizeof operator
+  return sizeof (*this);
+};
+
+
 
 void DataOutBase::GnuplotFlags::declare_parameters (ParameterHandler &/*prm*/)
 {};
@@ -56,6 +66,17 @@ void DataOutBase::GnuplotFlags::parse_parameters (ParameterHandler &/*prm*/)
 
 
 
+unsigned int
+DataOutBase::GnuplotFlags::memory_consumption () const
+{
+				   // only simple data elements, so
+				   // use sizeof operator
+  return sizeof (*this);
+};
+
+
+
+
 void DataOutBase::PovrayFlags::declare_parameters (ParameterHandler &prm)
 {
   prm.declare_entry ("Use smooth triangles", "false",
@@ -77,6 +98,16 @@ void DataOutBase::PovrayFlags::parse_parameters (ParameterHandler &prm)
 
 
 
+unsigned int
+DataOutBase::PovrayFlags::memory_consumption () const
+{
+				   // only simple data elements, so
+				   // use sizeof operator
+  return sizeof (*this);
+};
+
+
+
 DataOutBase::EpsFlags::EpsFlags (const unsigned int  height_vector,
 				 const unsigned int  color_vector,
 				 const SizeType      size_type,
@@ -267,6 +298,16 @@ void DataOutBase::EpsFlags::parse_parameters (ParameterHandler &prm)
 
 
 
+unsigned int
+DataOutBase::EpsFlags::memory_consumption () const
+{
+				   // only simple data elements, so
+				   // use sizeof operator
+  return sizeof (*this);
+};
+
+
+
 void DataOutBase::GmvFlags::declare_parameters (ParameterHandler &/*prm*/)
 {};
 
@@ -274,3 +315,21 @@ void DataOutBase::GmvFlags::declare_parameters (ParameterHandler &/*prm*/)
 
 void DataOutBase::GmvFlags::parse_parameters (ParameterHandler &/*prm*/)
 {};
+
+
+unsigned int
+DataOutBase::GmvFlags::memory_consumption () const
+{
+				   // only simple data elements, so
+				   // use sizeof operator
+  return sizeof (*this);
+};
+
+
+
+unsigned int DataOutBase::memory_consumption ()
+{
+  return 0;
+};
+
+
diff --git a/deal.II/base/source/data_out_base.cc b/deal.II/base/source/data_out_base.cc
index 32238b275d..ea55db556b 100644
--- a/deal.II/base/source/data_out_base.cc
+++ b/deal.II/base/source/data_out_base.cc
@@ -15,6 +15,7 @@
 #include <base/data_out_base.h>
 #include <base/parameter_handler.h>
 #include <base/thread_management.h>
+#include <base/memory_consumption.h>
 
 #include <iomanip>
 #include <ctime>
@@ -34,6 +35,20 @@ DataOutBase::Patch<dim,spacedim>::Patch () :
 
 
 
+template <int dim, int spacedim>
+unsigned int
+DataOutBase::Patch<dim,spacedim>::memory_consumption () const
+{
+  return (sizeof(vertices) / sizeof(vertices[0]) * 
+	  MemoryConsumption::memory_consumption(vertices[0])
+	  +
+	  MemoryConsumption::memory_consumption(n_subdivisions)
+	  +
+	  MemoryConsumption::memory_consumption(data));
+};
+
+
+
 template <int dim, int spacedim>
 void DataOutBase::write_ucd (const vector<Patch<dim,spacedim> > &patches,
 			     const vector<string>               &data_names,
@@ -1774,7 +1789,6 @@ DataOutBase::write_gmv_reorder_data_vectors (const vector<Patch<dim,spacedim> >
 
 
 
-
 /* --------------------------- class DataOutInterface ---------------------- */
 
 
@@ -2031,6 +2045,21 @@ void DataOutInterface<dim,spacedim>::parse_parameters (ParameterHandler &prm)
 }
 
 
+template <int dim, int spacedim>
+unsigned int 
+DataOutInterface<dim,spacedim>::memory_consumption () const
+{
+  return (sizeof (default_fmt) +
+	  MemoryConsumption::memory_consumption (ucd_flags) +
+	  MemoryConsumption::memory_consumption (gnuplot_flags) +
+	  MemoryConsumption::memory_consumption (povray_flags) +
+	  MemoryConsumption::memory_consumption (eps_flags) +
+	  MemoryConsumption::memory_consumption (gmv_flags));
+};
+
+
+
+
 // explicit instantiations. functions in DataOutBase are instantiated by
 // the respective functions in DataOut_Interface
 template class DataOutInterface<data_out_dimension,data_out_dimension>;
diff --git a/deal.II/base/source/function.cc b/deal.II/base/source/function.cc
index aa19b5436e..3444ced4eb 100644
--- a/deal.II/base/source/function.cc
+++ b/deal.II/base/source/function.cc
@@ -175,6 +175,18 @@ void Function<dim>::vector_laplacian_list (const vector<Point<dim> > &points,
     this->vector_laplacian (points[i], laplacians[i]);
 }
 
+
+
+template <int dim>
+unsigned int
+Function<dim>::memory_consumption () const
+{
+				   // only simple data elements, so
+				   // use sizeof operator
+  return sizeof (*this);
+};
+
+
 //------------------------------------------------------------//
 
 template <int dim>
@@ -341,6 +353,17 @@ void ConstantFunction<dim>::vector_value_list (const vector<Point<dim> > &points
     };
 };
 
+
+
+template <int dim>
+unsigned int
+ConstantFunction<dim>::memory_consumption () const
+{
+				   // only simple data elements, so
+				   // use sizeof operator
+  return sizeof (*this);
+};
+
 //------------------------------------------------------------//
 
 template <int dim>
@@ -383,6 +406,17 @@ void ComponentSelectFunction<dim>::vector_value_list (const vector<Point<dim> >
 }
 
 
+
+template <int dim>
+unsigned int
+ComponentSelectFunction<dim>::memory_consumption () const
+{
+				   // only simple data elements, so
+				   // use sizeof operator
+  return sizeof (*this);
+};
+
+
 // explicit instantiations
 
 template class Function<1>;
diff --git a/deal.II/base/source/function_derivative.cc b/deal.II/base/source/function_derivative.cc
index e6d8ed0978..f1abe317c3 100644
--- a/deal.II/base/source/function_derivative.cc
+++ b/deal.II/base/source/function_derivative.cc
@@ -20,10 +20,10 @@
 template <int dim>
 FunctionDerivative<dim>::FunctionDerivative (const Function<dim>& f,
 					     const Point<dim>& dir)
-  :
-  Function<dim> (f.n_components, f.get_time()),
-  f(f),
-  direction(dir)
+		:
+		Function<dim> (f.n_components, f.get_time()),
+		f(f),
+		direction(dir)
 {
   set_h();
   set_formula();
@@ -57,15 +57,15 @@ FunctionDerivative<dim>::value (const Point<dim>   &p,
 {
   switch (formula)
     {
-    case Euler:
-      return (f.value(p+incr, component)-f.value(p-incr, component))/(2*h);
-    case UpwindEuler:
-      return (f.value(p, component)-f.value(p-incr, component))/h;
-    case FourthOrder:
-      return (-f.value(p+2*incr, component) + 8*f.value(p+incr, component)
-	      -8*f.value(p-incr, component) + f.value(p-2*incr, component))/(12*h);
-    default:
-      Assert(false, ExcInvalidFormula());
+      case Euler:
+	    return (f.value(p+incr, component)-f.value(p-incr, component))/(2*h);
+      case UpwindEuler:
+	    return (f.value(p, component)-f.value(p-incr, component))/h;
+      case FourthOrder:
+	    return (-f.value(p+2*incr, component) + 8*f.value(p+incr, component)
+		    -8*f.value(p-incr, component) + f.value(p-2*incr, component))/(12*h);
+      default:
+	    Assert(false, ExcInvalidFormula());
     }
   return 0.;
 }
@@ -147,6 +147,17 @@ FunctionDerivative<dim>::value_list (const vector<Point<dim> > &points,
 }
 
 
+
+template <int dim>
+unsigned int
+FunctionDerivative<dim>::memory_consumption () const
+{
+				   // only simple data elements, so
+				   // use sizeof operator
+  return sizeof (*this);
+};
+
+
 template FunctionDerivative<1>;
 template FunctionDerivative<2>;
 template FunctionDerivative<3>;
diff --git a/deal.II/base/source/function_lib.cc b/deal.II/base/source/function_lib.cc
index b27e0e391f..66df13b319 100644
--- a/deal.II/base/source/function_lib.cc
+++ b/deal.II/base/source/function_lib.cc
@@ -888,6 +888,17 @@ JumpFunction<dim>::gradient_list (const vector<Point<dim> > &p,
 }
 
 
+
+template <int dim>
+unsigned int
+JumpFunction<dim>::memory_consumption () const
+{
+				   // only simple data elements, so
+				   // use sizeof operator
+  return sizeof (*this);
+};
+
+
 template SquareFunction<1>;
 template SquareFunction<2>;
 template SquareFunction<3>;
diff --git a/deal.II/base/source/log.cc b/deal.II/base/source/log.cc
index a799ae2b1e..88c4c2494b 100644
--- a/deal.II/base/source/log.cc
+++ b/deal.II/base/source/log.cc
@@ -14,6 +14,7 @@
 
 #include <base/logstream.h>
 #include <base/job_identifier.h>
+#include <base/memory_consumption.h>
 
 #include <sys/resource.h>
 #include <iomanip>
@@ -141,3 +142,21 @@ LogStream::operator << (void (f)(LogStream &))
 }
 
 
+
+unsigned int
+LogStream::memory_consumption () const
+{
+  unsigned int mem = sizeof(*this);
+				   // to determine size of stack
+				   // elements, we have to copy the
+				   // stack since we can't access
+				   // elements from further below
+  stack<string> tmp;
+  while (tmp.size() > 0)
+    {
+      mem += MemoryConsumption::memory_consumption (tmp.top());
+      tmp.pop ();
+    };
+  
+  return mem;
+};
diff --git a/deal.II/base/source/memory_consumption.cc b/deal.II/base/source/memory_consumption.cc
new file mode 100644
index 0000000000..62a2177a87
--- /dev/null
+++ b/deal.II/base/source/memory_consumption.cc
@@ -0,0 +1,36 @@
+//----------------------------  function.cc  ---------------------------
+//    $Id$
+//    Version: $Name$
+//
+//    Copyright (C) 1998, 1999, 2000 by the deal.II authors
+//
+//    This file is subject to QPL and may not be  distributed
+//    without copyright and license information. Please refer
+//    to the file deal.II/doc/license.html for the  text  and
+//    further information on this license.
+//
+//----------------------------  function.cc  ---------------------------
+
+
+#include <base/memory_consumption.h>
+
+
+namespace MemoryConsumption 
+{
+  unsigned int memory_consumption (const string &s)
+  {
+    return sizeof(s) + s.length();
+  };
+
+
+   
+  unsigned int memory_consumption (const vector<string> &v)
+    {
+      unsigned int mem = sizeof(v);
+      for (unsigned int i=0; i<v.size(); ++i)
+	mem += memory_consumption(v[i]);
+      return mem;
+    };
+  
+
+};
diff --git a/deal.II/base/source/multithread_info.cc b/deal.II/base/source/multithread_info.cc
index 7931d80141..4e5a3061c2 100644
--- a/deal.II/base/source/multithread_info.cc
+++ b/deal.II/base/source/multithread_info.cc
@@ -90,6 +90,15 @@ MultithreadInfo::MultithreadInfo () :
 
 
 
+unsigned int
+MultithreadInfo::memory_consumption ()
+{
+				   // only simple data elements, so
+				   // use sizeof operator
+  return sizeof (MultithreadInfo);
+};
+
+
 
 // definition of the variable which is declared `extern' in the .h file
 MultithreadInfo multithread_info;
diff --git a/deal.II/base/source/parameter_handler.cc b/deal.II/base/source/parameter_handler.cc
index 9b49941a22..d14c953178 100644
--- a/deal.II/base/source/parameter_handler.cc
+++ b/deal.II/base/source/parameter_handler.cc
@@ -14,6 +14,7 @@
 
 #include <base/parameter_handler.h>
 #include <base/logstream.h>
+#include <base/memory_consumption.h>
 #include <fstream>
 #include <iomanip>
 #include <strstream>
@@ -30,6 +31,23 @@ namespace Patterns
   {};
 
 
+  unsigned int
+    PatternBase::memory_consumption () const
+    {
+      if (dynamic_cast<const Integer*>(this) != 0)
+	return sizeof(Integer);
+      else if (dynamic_cast<const Double*>(this) != 0)
+	return sizeof(Double);
+      else if (dynamic_cast<const Bool*>(this) != 0)
+	return sizeof(Bool);
+      else if (dynamic_cast<const Anything*>(this) != 0)
+	return sizeof(Anything);
+      else
+	return sizeof(*this) + 32;
+    };
+  
+
+
 
   Integer::Integer (const int lower_bound,
 		    const int upper_bound) :
@@ -195,6 +213,13 @@ namespace Patterns
   };
 
 
+  unsigned int
+    Selection::memory_consumption () const
+    {
+      return (sizeof(PatternBase) +
+	      MemoryConsumption::memory_consumption(sequence));
+    };
+  
 
   MultipleSelection::MultipleSelection (const string &seq)
   {
@@ -287,6 +312,14 @@ namespace Patterns
   };
 
 
+  unsigned int
+    MultipleSelection::memory_consumption () const
+    {
+      return (sizeof(PatternBase) +
+	      MemoryConsumption::memory_consumption(sequence));
+    };
+
+
 
   Bool::Bool () :
 		  Selection ("true|false")
@@ -767,7 +800,7 @@ void ParameterHandler::print_parameters_section (ostream           &out,
 
 
 
-void ParameterHandler::log_parameters_section (LogStream           &out)
+void ParameterHandler::log_parameters_section (LogStream &out)
 {
   Section *pd = get_present_defaults_subsection ();
   Section *pc = get_present_changed_subsection ();
@@ -1002,7 +1035,20 @@ const ParameterHandler::Section* ParameterHandler::get_present_changed_subsectio
 };
 
 
-ParameterHandler::Section::~Section () {
+
+unsigned int 
+ParameterHandler::memory_consumption () const
+{
+  return (MemoryConsumption::memory_consumption (status) +
+	  MemoryConsumption::memory_consumption (subsection_path) +
+	  MemoryConsumption::memory_consumption (defaults) +
+	  MemoryConsumption::memory_consumption (changed_entries));
+};
+
+
+
+ParameterHandler::Section::~Section () 
+{
   entries.clear ();
 
   map<string, Section*>::iterator p;
@@ -1010,12 +1056,28 @@ ParameterHandler::Section::~Section () {
   for (p=subsections.begin(); p!=subsections.end(); ++p)
     delete p->second;
 
+  subsections.clear ();
+};
+
+
 
-subsections.clear ();
+unsigned int 
+ParameterHandler::Section::memory_consumption () const
+{
+  unsigned int mem = 0;
+  for (EntryType::const_iterator i=entries.begin(); i!=entries.end(); ++i)
+    mem += (MemoryConsumption::memory_consumption (i->first) +
+	    MemoryConsumption::memory_consumption (i->second.first) +
+	    MemoryConsumption::memory_consumption (*i->second.second));
+  for (map<string, Section*>::const_iterator i=subsections.begin(); i!=subsections.end(); ++i)
+    mem += (MemoryConsumption::memory_consumption (i->first) +
+	    MemoryConsumption::memory_consumption (*(i->second)));
+  return mem;
 };
 
 
 
+
 MultipleParameterLoop::MultipleParameterLoop() :
 		n_branches(0)
 {};
@@ -1224,6 +1286,19 @@ void MultipleParameterLoop::fill_entry_values (const unsigned int run_no)
 
 
 
+
+unsigned int 
+MultipleParameterLoop::memory_consumption () const
+{
+  unsigned int mem = ParameterHandler::memory_consumption ();
+  for (unsigned int i=0; i<multiple_choices.size(); ++i)
+    mem += multiple_choices[i].memory_consumption ();
+  
+  return mem;
+};
+
+
+
 MultipleParameterLoop::Entry::Entry (const vector<string> &ssp,
 				     const string& Name,
 				     const string& Value) :
@@ -1279,3 +1354,13 @@ void MultipleParameterLoop::Entry::split_different_values ()
 };
 
 
+unsigned int 
+MultipleParameterLoop::Entry::memory_consumption () const
+{
+  return (MemoryConsumption::memory_consumption (subsection_path) +
+	  MemoryConsumption::memory_consumption (entry_name) +
+	  MemoryConsumption::memory_consumption (entry_value) +
+	  MemoryConsumption::memory_consumption (different_values) +
+	  sizeof (type));
+};
+
diff --git a/deal.II/base/source/quadrature.cc b/deal.II/base/source/quadrature.cc
index e95a9adedf..4009ab68ba 100644
--- a/deal.II/base/source/quadrature.cc
+++ b/deal.II/base/source/quadrature.cc
@@ -14,6 +14,7 @@
 
 #include <grid/geometry_info.h>
 #include <base/quadrature.h>
+#include <base/memory_consumption.h>
 #include <cmath>
 
 
@@ -179,6 +180,16 @@ const vector<double> & Quadrature<0>::get_weights () const
 
 
 
+template <int dim>
+unsigned int
+Quadrature<dim>::memory_consumption () const
+{
+  return (MemoryConsumption::memory_consumption (quadrature_points) +
+	  MemoryConsumption::memory_consumption (weights));
+};
+
+
+
 template <>
 void QProjector<2>::project_to_face (const Quadrature<1> &quadrature,
 				     const unsigned int   face_no,
diff --git a/deal.II/deal.II/include/dofs/dof_constraints.h b/deal.II/deal.II/include/dofs/dof_constraints.h
index 526304a923..62999bfb9e 100644
--- a/deal.II/deal.II/include/dofs/dof_constraints.h
+++ b/deal.II/deal.II/include/dofs/dof_constraints.h
@@ -386,6 +386,13 @@ class ConstraintMatrix : public Subscriptor
 				      */
     void print (ostream &) const;
 
+				     /**
+				      * Determine an estimate for the
+				      * memory consumption (in bytes)
+				      * of this object.
+				      */
+    unsigned int memory_consumption () const;
+
 
 				     /**
 				      * Exception
diff --git a/deal.II/deal.II/include/dofs/dof_handler.h b/deal.II/deal.II/include/dofs/dof_handler.h
index a63945377e..4fcd1af23d 100644
--- a/deal.II/deal.II/include/dofs/dof_handler.h
+++ b/deal.II/deal.II/include/dofs/dof_handler.h
@@ -1000,6 +1000,20 @@ class DoFHandler  :  public Subscriptor,
 				      */
     const Triangulation<dim> & get_tria () const;
     
+				     /**
+				      * Determine an estimate for the
+				      * memory consumption (in bytes)
+				      * of this object.
+				      *
+				      * This function is made virtual,
+				      * since a dof handler object
+				      * might be accessed through a
+				      * pointers to thisr base class,
+				      * although the actual object
+				      * might be a derived class.
+				      */
+    virtual unsigned int memory_consumption () const;
+
 				     /**
 				      * Exception
 				      */
diff --git a/deal.II/deal.II/include/dofs/dof_levels.h b/deal.II/deal.II/include/dofs/dof_levels.h
index a5c11806ea..931a76de10 100644
--- a/deal.II/deal.II/include/dofs/dof_levels.h
+++ b/deal.II/deal.II/include/dofs/dof_levels.h
@@ -91,6 +91,13 @@ class DoFLevel<1>
 				      * detailed information.
 				      */
     vector<unsigned int> line_dofs;
+
+				     /**
+				      * Determine an estimate for the
+				      * memory consumption (in bytes)
+				      * of this object.
+				      */
+    unsigned int memory_consumption () const;
 };
 
 
@@ -111,6 +118,13 @@ class DoFLevel<2> : public DoFLevel<1>
 				      * detailed information.
 				      */
     vector<unsigned int> quad_dofs;
+
+				     /**
+				      * Determine an estimate for the
+				      * memory consumption (in bytes)
+				      * of this object.
+				      */
+    unsigned int memory_consumption () const;
 };
 
 
@@ -131,6 +145,13 @@ class DoFLevel<3> : public DoFLevel<2>
 				      * detailed information.
 				      */
     vector<unsigned int> hex_dofs;
+
+				     /**
+				      * Determine an estimate for the
+				      * memory consumption (in bytes)
+				      * of this object.
+				      */
+    unsigned int memory_consumption () const;
 };
 
 
diff --git a/deal.II/deal.II/include/fe/fe.h b/deal.II/deal.II/include/fe/fe.h
index ebd8319e3a..e76da58d47 100644
--- a/deal.II/deal.II/include/fe/fe.h
+++ b/deal.II/deal.II/include/fe/fe.h
@@ -349,6 +349,19 @@ class FiniteElementBase : public Subscriptor,
 				      */
     bool restriction_is_additive (const unsigned int component) const;
 
+				     /**
+				      * Determine an estimate for the
+				      * memory consumption (in bytes)
+				      * of this object.
+				      *
+				      * This function is made virtual,
+				      * since finite element objects
+				      * are usually accessed through
+				      * pointers to their base class,
+				      * rather than the class itself.
+				      */
+    virtual unsigned int memory_consumption () const;
+
 				     /**
 				      * Exception
 				      */
diff --git a/deal.II/deal.II/include/fe/fe_lib.criss_cross.h b/deal.II/deal.II/include/fe/fe_lib.criss_cross.h
index d927390925..3a0a8eca4c 100644
--- a/deal.II/deal.II/include/fe/fe_lib.criss_cross.h
+++ b/deal.II/deal.II/include/fe/fe_lib.criss_cross.h
@@ -172,7 +172,8 @@
  * @author Wolfgang Bangerth, 1998
  */
 template <int dim>
-class FECrissCross : public FiniteElement<dim> {
+class FECrissCross : public FiniteElement<dim> 
+{
   public:
     				     /**
 				      * Constructor
@@ -348,6 +349,7 @@ class FECrissCross : public FiniteElement<dim> {
 };
 
 
+
 /**
  * Quadrature formula for the criss-cross element. This quadrature
  * formula uses one point at the barycenter of each of the four subtriangles.
@@ -356,7 +358,8 @@ class FECrissCross : public FiniteElement<dim> {
  * formula is not implemented for one space dimension.
  */
 template <int dim>
-class QCrissCross1 : public Quadrature<dim> {
+class QCrissCross1 : public Quadrature<dim> 
+{
   public:
     QCrissCross1 ();
 
diff --git a/deal.II/deal.II/include/fe/fe_system.h b/deal.II/deal.II/include/fe/fe_system.h
index 74cbf06841..de52dd70b6 100644
--- a/deal.II/deal.II/include/fe/fe_system.h
+++ b/deal.II/deal.II/include/fe/fe_system.h
@@ -430,6 +430,19 @@ class FESystem : public FiniteElement<dim>
 				      */
     virtual const FiniteElement<dim>& base_element(unsigned int index) const;
 
+				     /**
+				      * Determine an estimate for the
+				      * memory consumption (in bytes)
+				      * of this object.
+				      *
+				      * This function is made virtual,
+				      * since finite element objects
+				      * are usually accessed through
+				      * pointers to their base class,
+				      * rather than the class itself.
+				      */
+    virtual unsigned int memory_consumption () const;
+
   private:
 
 				     /**
@@ -449,7 +462,7 @@ class FESystem : public FiniteElement<dim>
 				      * created by the constructor and
 				      * constant afterwards.
 				      */
-    vector< ElementPair > base_elements;
+    vector<ElementPair> base_elements;
 
 
 				     /**
diff --git a/deal.II/deal.II/include/fe/fe_values.h b/deal.II/deal.II/include/fe/fe_values.h
index e32fdc8ba6..60721f32f1 100644
--- a/deal.II/deal.II/include/fe/fe_values.h
+++ b/deal.II/deal.II/include/fe/fe_values.h
@@ -584,6 +584,13 @@ class FEValuesBase
 				      */
     const DoFHandler<dim>::cell_iterator & get_cell() const;
 
+				     /**
+				      * Determine an estimate for the
+				      * memory consumption (in bytes)
+				      * of this object.
+				      */
+    unsigned int memory_consumption () const;
+
 				     /**
 				      * Exception
 				      */
@@ -787,6 +794,7 @@ class FEValuesBase
 };
 
 
+
 /**
  * Represent a finite element evaluated with a specific quadrature rule on
  * a cell.
@@ -852,6 +860,13 @@ class FEValues : public FEValuesBase<dim>
 				      */
     void reinit (const typename DoFHandler<dim>::cell_iterator &);
 
+				     /**
+				      * Determine an estimate for the
+				      * memory consumption (in bytes)
+				      * of this object.
+				      */
+    unsigned int memory_consumption () const;
+
   private:
 				     /**
 				      * Store the gradients of the shape
@@ -1009,6 +1024,13 @@ class FEFaceValuesBase : public FEValuesBase<dim>
 				      */
     DoFHandler<dim>::face_iterator get_face() const;
 
+				     /**
+				      * Determine an estimate for the
+				      * memory consumption (in bytes)
+				      * of this object.
+				      */
+    unsigned int memory_consumption () const;
+
 
   protected:
 				     /**
@@ -1090,6 +1112,7 @@ class FEFaceValuesBase : public FEValuesBase<dim>
 };
 
 
+
 /**
  * Represent a finite element evaluated with a specific quadrature rule on
  * the face of a cell.
diff --git a/deal.II/deal.II/include/grid/grid_out.h b/deal.II/deal.II/include/grid/grid_out.h
index d0f0c30a3f..c7e7780576 100644
--- a/deal.II/deal.II/include/grid/grid_out.h
+++ b/deal.II/deal.II/include/grid/grid_out.h
@@ -548,6 +548,12 @@ class GridOut
 				      */
     static string get_output_format_names ();
 
+				     /**
+				      * Determine an estimate for the
+				      * memory consumption (in bytes)
+				      * of this object.
+				      */
+    unsigned int memory_consumption () const;
 
 				     /**
 				      * Exception
diff --git a/deal.II/deal.II/include/grid/intergrid_map.h b/deal.II/deal.II/include/grid/intergrid_map.h
index 527e6a0579..d654f2ff3c 100644
--- a/deal.II/deal.II/include/grid/intergrid_map.h
+++ b/deal.II/deal.II/include/grid/intergrid_map.h
@@ -175,6 +175,13 @@ class InterGridMap
 				      * destination grid.
 				      */
     const GridClass<dim> & get_destination_grid () const;
+
+				     /**
+				      * Determine an estimate for the
+				      * memory consumption (in bytes)
+				      * of this object.
+				      */
+    unsigned int memory_consumption () const;
     
 				     /**
 				      * Exception
diff --git a/deal.II/deal.II/include/grid/persistent_tria.h b/deal.II/deal.II/include/grid/persistent_tria.h
index 82c83753c5..61558aef80 100644
--- a/deal.II/deal.II/include/grid/persistent_tria.h
+++ b/deal.II/deal.II/include/grid/persistent_tria.h
@@ -200,6 +200,13 @@ class PersistentTriangulation : public Triangulation<dim>
 				      */
     virtual void read_flags(istream &in);
 
+				     /**
+				      * Determine an estimate for the
+				      * memory consumption (in bytes)
+				      * of this object.
+				      */
+    virtual unsigned int memory_consumption () const;
+
 				     /**
 				      * Exception.
 				      */
diff --git a/deal.II/deal.II/include/grid/tria.h b/deal.II/deal.II/include/grid/tria.h
index 51d5239bef..a77b956102 100644
--- a/deal.II/deal.II/include/grid/tria.h
+++ b/deal.II/deal.II/include/grid/tria.h
@@ -398,6 +398,13 @@ struct TriaNumberCache<1>
 				      * by default.
 				      */
     TriaNumberCache ();
+
+				     /**
+				      * Determine an estimate for the
+				      * memory consumption (in bytes)
+				      * of this object.
+				      */
+    unsigned int memory_consumption () const;
 };
 
 
@@ -451,6 +458,13 @@ struct TriaNumberCache<2> : public TriaNumberCache<1>
 				      * by default.
 				      */
     TriaNumberCache ();
+
+				     /**
+				      * Determine an estimate for the
+				      * memory consumption (in bytes)
+				      * of this object.
+				      */
+    unsigned int memory_consumption () const;
 };
 
 
@@ -504,6 +518,13 @@ struct TriaNumberCache<3> : public TriaNumberCache<2>
 				      * by default.
 				      */
     TriaNumberCache ();
+
+				     /**
+				      * Determine an estimate for the
+				      * memory consumption (in bytes)
+				      * of this object.
+				      */
+    unsigned int memory_consumption () const;
 };
 
 
@@ -2842,6 +2863,20 @@ class Triangulation : public TriaDimensionInfo<dim>,
     unsigned int max_adjacent_cells () const;
     				     /*@}*/
 
+				     /**
+				      * Determine an estimate for the
+				      * memory consumption (in bytes)
+				      * of this object.
+				      *
+				      * This function is made virtual,
+				      * since a triangulation object
+				      * might be accessed through a
+				      * pointer to this base class,
+				      * even if the actual object is a
+				      * derived class.
+				      */
+    virtual unsigned int memory_consumption () const;
+    
 
 				     /**
 				      *  @name Exceptions
@@ -2981,7 +3016,7 @@ class Triangulation : public TriaDimensionInfo<dim>,
 				  vector<bool>       &v,
 				  const unsigned int  magic_number2,
 				  istream            &in);
-    
+
   private:
 				     /**
 				      *  Refine all cells on all levels which
@@ -3089,7 +3124,13 @@ class Triangulation : public TriaDimensionInfo<dim>,
     vector<bool>                     vertices_used;
 
 				     /**
-				      *  Collection of boundary objects.
+				      *  Collection of boundary
+				      *  objects. We only need 255
+				      *  objects rather than 256,
+				      *  since the indicator 255 is
+				      *  reserved for interior faces
+				      *  and can thus never be
+				      *  associated with a boundary.
 				      */
     const Boundary<dim>* boundary[255];
 
diff --git a/deal.II/deal.II/include/grid/tria_hex.h b/deal.II/deal.II/include/grid/tria_hex.h
index 86f8e18fa8..d4fa9f5ae1 100644
--- a/deal.II/deal.II/include/grid/tria_hex.h
+++ b/deal.II/deal.II/include/grid/tria_hex.h
@@ -64,6 +64,13 @@ class Hexahedron
 				      */
     void set_quad (const int i, const int index);
     
+				     /**
+				      * Determine an estimate for the
+				      * memory consumption (in bytes)
+				      * of this object.
+				      */
+    static unsigned int memory_consumption ();
+
 				     /**
 				      *  Exception
 				      */ 
@@ -113,4 +120,12 @@ void Hexahedron::set_quad (const int i, const int index)
 };
 
 
+
+inline
+unsigned int
+Hexahedron::memory_consumption ()
+{
+  return sizeof(Hexahedron);
+};
+
 #endif
diff --git a/deal.II/deal.II/include/grid/tria_iterator.h b/deal.II/deal.II/include/grid/tria_iterator.h
index 87d88a2a0d..b1ba1a4d16 100644
--- a/deal.II/deal.II/include/grid/tria_iterator.h
+++ b/deal.II/deal.II/include/grid/tria_iterator.h
@@ -460,6 +460,14 @@ class TriaRawIterator : public bidirectional_iterator<Accessor,int>
     void print (ostream &out) const;
 
 
+				     /**
+				      * Determine an estimate for the
+				      * memory consumption (in bytes)
+				      * of this object.
+				      */
+    unsigned int memory_consumption () const;
+
+
 				     /**@name Exceptions*/
 				     /*@{*/
 				     /**
@@ -507,7 +515,8 @@ class TriaRawIterator : public bidirectional_iterator<Accessor,int>
  *   @em{used} lines, quads, cells, etc.
  */
 template <int dim, typename Accessor>
-class TriaIterator : public TriaRawIterator<dim,Accessor> {
+class TriaIterator : public TriaRawIterator<dim,Accessor> 
+{
   public:
 				     /**
 				      *  Empty constructor. Such an object
@@ -653,7 +662,8 @@ class TriaIterator : public TriaRawIterator<dim,Accessor> {
  *   refined and thus a cell on which calculations on the finest level are done.
  */
 template <int dim, typename Accessor>
-class TriaActiveIterator : public TriaIterator<dim,Accessor> {
+class TriaActiveIterator : public TriaIterator<dim,Accessor> 
+{
   public:
 				     /**
 				      *  Empty constructor. Such an object
@@ -940,6 +950,16 @@ TriaRawIterator<dim,Accessor>::print (ostream &out) const
 
 
 
+template <int dim, typename Accessor>
+inline
+unsigned int
+TriaRawIterator<dim,Accessor>::memory_consumption () const
+{
+  return sizeof(TriaRawIterator<dim,Accessor>);
+};
+
+
+
 template <int dim, typename Accessor>
 template <typename OtherAccessor>
 inline
diff --git a/deal.II/deal.II/include/grid/tria_levels.h b/deal.II/deal.II/include/grid/tria_levels.h
index b4dcba9959..7d622d6c78 100644
--- a/deal.II/deal.II/include/grid/tria_levels.h
+++ b/deal.II/deal.II/include/grid/tria_levels.h
@@ -156,6 +156,13 @@ class TriangulationLevel<0>
 				      */
     void monitor_memory (const unsigned int true_dimension) const;
 
+				     /**
+				      * Determine an estimate for the
+				      * memory consumption (in bytes)
+				      * of this object.
+				      */
+    unsigned int memory_consumption () const;
+
 				     /**
 				      *  Exception
 				      */
@@ -318,6 +325,13 @@ class TriangulationLevel<1> : public TriangulationLevel<0>
 				      *  @ref{TriangulationLevel} classes.
 				      */
     void monitor_memory (const unsigned int true_dimension) const;
+
+				     /**
+				      * Determine an estimate for the
+				      * memory consumption (in bytes)
+				      * of this object.
+				      */
+    unsigned int memory_consumption () const;
 };
 
 
@@ -353,21 +367,26 @@ class TriangulationLevel<2> :  public TriangulationLevel<1>
 					  */
 	vector<Quad> quads;
 					 /**
-					  *  Same as for the @ref{TriangulationLevel<1>::LinesData}@p{::chilren}
-					  *  array, but since there are four
-					  *  children, the index points to the
-					  *  first while the other three are
-					  *  following immediately afterwards.
+					  *  Same as for the
+					  *  @ref{TriangulationLevel<1>::LinesData}@p{::chilren}
+					  *  array, but since there
+					  *  are four children, the
+					  *  index points to the first
+					  *  while the other three are
+					  *  following immediately
+					  *  afterwards.
 					  */
 	vector<int>  children;
 
 					 /**
-					  *  Same as for @ref{TriangulationLevel<1>::LinesData}@p{::used}.
+					  *  Same as for
+					  *  @ref{TriangulationLevel<1>::LinesData}@p{::used}.
 					  */
 	vector<bool> used;
 
 					 /**
-					  *  Same as for @ref{TriangulationLevel<1>::LinesData}@p{::used}.
+					  *  Same as for
+					  *  @ref{TriangulationLevel<1>::LinesData}@p{::used}.
 					  */
 	vector<bool> user_flags;
 
@@ -425,6 +444,13 @@ class TriangulationLevel<2> :  public TriangulationLevel<1>
 				      *  @ref{TriangulationLevel} classes.
 				      */
     void monitor_memory (const unsigned int true_dimension) const;
+
+				     /**
+				      * Determine an estimate for the
+				      * memory consumption (in bytes)
+				      * of this object.
+				      */
+    unsigned int memory_consumption () const;
 };
 
 
@@ -450,7 +476,8 @@ class TriangulationLevel<3> :  public TriangulationLevel<2>
 				      *  level.
 				      *
 				      *  It is fully analogous to the
-				      *  @ref{TriangulationLevel<1>::LinesData} structure inherited from
+				      *  @ref{TriangulationLevel<1>::LinesData}
+				      *  structure inherited from
 				      *  @ref{Triangulation<1>}.
 				      */
     struct HexesData
@@ -460,21 +487,26 @@ class TriangulationLevel<3> :  public TriangulationLevel<2>
 					  */
 	vector<Hexahedron> hexes;
 					 /**
-					  *  Same as for the @ref{TriangulationLevel<1>::LinesData}@p{::chilren}
-					  *  array, but since there are four
-					  *  children, the index points to the
-					  *  first while the other three are
-					  *  following immediately afterwards.
+					  *  Same as for the
+					  *  @ref{TriangulationLevel<1>::LinesData}@p{::chilren}
+					  *  array, but since there
+					  *  are four children, the
+					  *  index points to the first
+					  *  while the other three are
+					  *  following immediately
+					  *  afterwards.
 					  */
 	vector<int>  children;
 
 					 /**
-					  *  Same as for @ref{TriangulationLevel<1>::LinesData}@p{::used}.
+					  *  Same as for
+					  *  @ref{TriangulationLevel<1>::LinesData}@p{::used}.
 					  */
 	vector<bool> used;
 
 					 /**
-					  *  Same as for @ref{TriangulationLevel<1>::LinesData}@p{::used}.
+					  *  Same as for
+					  *  @ref{TriangulationLevel<1>::LinesData}@p{::used}.
 					  */
 	vector<bool> user_flags;
 
@@ -532,6 +564,13 @@ class TriangulationLevel<3> :  public TriangulationLevel<2>
 				      *  @ref{TriangulationLevel} classes.
 				      */
     void monitor_memory (const unsigned int true_dimension) const;
+
+				     /**
+				      * Determine an estimate for the
+				      * memory consumption (in bytes)
+				      * of this object.
+				      */
+    unsigned int memory_consumption () const;
 };
 
 
diff --git a/deal.II/deal.II/include/grid/tria_line.h b/deal.II/deal.II/include/grid/tria_line.h
index ba4afc90ce..0f86ce87d3 100644
--- a/deal.II/deal.II/include/grid/tria_line.h
+++ b/deal.II/deal.II/include/grid/tria_line.h
@@ -52,6 +52,13 @@ class Line
 				      */
     void set_vertex (const int i, const int index);
     
+				     /**
+				      * Determine an estimate for the
+				      * memory consumption (in bytes)
+				      * of this object.
+				      */
+    static unsigned int memory_consumption ();
+
 				     /**
 				      *  Exception
 				      */
@@ -71,7 +78,7 @@ class Line
 /*----------------------------- Inline Function: Line ------------------------*/
 
 
-inline                               // wahrlich inline hier!
+inline                               // truly in-line here!
 Line::Line (const int i0, const int i1)
 {
   end_points[0] = i0;
@@ -99,4 +106,13 @@ void Line::set_vertex (const int i, const int index)
 };
 
 
+
+inline
+unsigned int
+Line::memory_consumption ()
+{
+  return sizeof(Line);
+};
+
+
 #endif
diff --git a/deal.II/deal.II/include/grid/tria_quad.h b/deal.II/deal.II/include/grid/tria_quad.h
index 56820e999d..61641c511c 100644
--- a/deal.II/deal.II/include/grid/tria_quad.h
+++ b/deal.II/deal.II/include/grid/tria_quad.h
@@ -60,6 +60,13 @@ class Quad
 				      */
     void set_line (const int i, const int index);
     
+				     /**
+				      * Determine an estimate for the
+				      * memory consumption (in bytes)
+				      * of this object.
+				      */
+    static unsigned int memory_consumption ();
+
 				     /**
 				      *  Exception
 				      */ 
@@ -105,4 +112,12 @@ void Quad::set_line (const int i, const int index)
 };
 
 
+
+inline
+unsigned int
+Quad::memory_consumption ()
+{
+  return sizeof(Quad);
+};
+
 #endif
diff --git a/deal.II/deal.II/source/dofs/dof_handler.cc b/deal.II/deal.II/source/dofs/dof_handler.cc
index e3336135d3..5fb6a07912 100644
--- a/deal.II/deal.II/source/dofs/dof_handler.cc
+++ b/deal.II/deal.II/source/dofs/dof_handler.cc
@@ -12,6 +12,7 @@
 //----------------------------  dof_handler.cc  ---------------------------
 
 
+#include <base/memory_consumption.h>
 #include <dofs/dof_handler.h>
 #include <dofs/dof_levels.h>
 #include <dofs/dof_accessor.h>
@@ -1253,6 +1254,24 @@ const Triangulation<dim> & DoFHandler<dim>::get_tria () const
 
 
 
+template <int dim>
+unsigned int
+DoFHandler<dim>::memory_consumption () const
+{
+  unsigned int mem = (MemoryConsumption::memory_consumption (tria) +
+		      MemoryConsumption::memory_consumption (selected_fe) +
+		      MemoryConsumption::memory_consumption (tria) +
+		      MemoryConsumption::memory_consumption (levels) +
+		      MemoryConsumption::memory_consumption (used_dofs) +
+		      MemoryConsumption::memory_consumption (vertex_dofs));
+  for (unsigned int i=0; i<levels.size(); ++i)
+    mem += MemoryConsumption::memory_consumption (*levels[i]);
+  
+  return mem;
+};
+
+
+
 template <int dim>
 void DoFHandler<dim>::distribute_dofs (const FiniteElement<dim> &ff,
 				       const unsigned int        offset)
diff --git a/deal.II/deal.II/source/dofs/dof_levels.cc b/deal.II/deal.II/source/dofs/dof_levels.cc
new file mode 100644
index 0000000000..bbde931123
--- /dev/null
+++ b/deal.II/deal.II/source/dofs/dof_levels.cc
@@ -0,0 +1,41 @@
+//----------------------------  dof_levels.cc  ---------------------------
+//    $Id$
+//    Version: $Name$
+//
+//    Copyright (C) 1998, 1999, 2000 by the deal.II authors
+//
+//    This file is subject to QPL and may not be  distributed
+//    without copyright and license information. Please refer
+//    to the file deal.II/doc/license.html for the  text  and
+//    further information on this license.
+//
+//----------------------------  dof_levels.cc  ---------------------------
+
+
+#include <base/memory_consumption.h>
+#include <dofs/dof_levels.h>
+
+
+unsigned int
+DoFLevel<1>::memory_consumption () const
+{
+  return MemoryConsumption::memory_consumption (line_dofs);
+};
+
+
+
+unsigned int
+DoFLevel<2>::memory_consumption () const
+{
+  return (DoFLevel<1>::memory_consumption () +
+	  MemoryConsumption::memory_consumption (quad_dofs));
+};
+
+
+
+unsigned int
+DoFLevel<3>::memory_consumption () const
+{
+  return (DoFLevel<2>::memory_consumption () +
+	  MemoryConsumption::memory_consumption (hex_dofs));
+};
diff --git a/deal.II/deal.II/source/fe/fe.cc b/deal.II/deal.II/source/fe/fe.cc
index d9234f41d7..6813a265d4 100644
--- a/deal.II/deal.II/source/fe/fe.cc
+++ b/deal.II/deal.II/source/fe/fe.cc
@@ -13,6 +13,7 @@
 
 
 #include <fe/fe.h>
+#include <base/memory_consumption.h>
 #include <base/quadrature.h>
 #include <grid/tria.h>
 #include <grid/tria_iterator.h>
@@ -246,6 +247,28 @@ bool FiniteElementBase<dim>::operator == (const FiniteElementBase<dim> &f) const
 };
 
 
+
+template <int dim>
+unsigned int
+FiniteElementBase<dim>::memory_consumption () const
+{
+  return (sizeof(FiniteElementData<dim>) +
+	  MemoryConsumption::
+	  memory_consumption<FullMatrix<double>, sizeof(restriction)/sizeof(restriction[0])>
+	  (restriction)+
+	  MemoryConsumption::memory_consumption
+	  <FullMatrix<double>, sizeof(prolongation)/sizeof(prolongation[0])>
+	  (prolongation) +
+	  MemoryConsumption::memory_consumption (interface_constraints) +
+	  MemoryConsumption::memory_consumption (system_to_component_table) +
+	  MemoryConsumption::memory_consumption (face_system_to_component_table) +
+	  MemoryConsumption::memory_consumption (component_to_system_table) +
+	  MemoryConsumption::memory_consumption (face_component_to_system_table) +
+	  MemoryConsumption::memory_consumption (component_to_base_table) +
+	  MemoryConsumption::memory_consumption (restriction_is_additive_flags));
+};
+
+
 /*------------------------------- FiniteElement ----------------------*/
 
 
diff --git a/deal.II/deal.II/source/fe/fe_system.cc b/deal.II/deal.II/source/fe/fe_system.cc
index 54979a122b..b91fe98f89 100644
--- a/deal.II/deal.II/source/fe/fe_system.cc
+++ b/deal.II/deal.II/source/fe/fe_system.cc
@@ -12,6 +12,7 @@
 //----------------------------  fe_system.cc  ---------------------------
 
 
+#include <base/memory_consumption.h>
 #include <fe/fe_system.h>
 #include <grid/tria_iterator.h>
 #include <dofs/dof_accessor.h>
@@ -1069,6 +1070,26 @@ FESystem<dim>::fill_fe_values (const DoFHandler<dim>::cell_iterator &cell,
 }
 
 
+
+template <int dim>
+unsigned int
+FESystem<dim>::memory_consumption () const 
+{
+				   // neglect size of data stored in
+				   // @p{base_elements} due to some
+				   // problems with teh
+				   // compiler. should be neglectable
+				   // after all, considering the size
+				   // of the data of the subelements
+  unsigned int mem = (FiniteElement<dim>::memory_consumption () +
+		      sizeof (base_elements));
+  for (unsigned int i=0; i<base_elements.size(); ++i)
+    mem += MemoryConsumption::memory_consumption (*base_elements[i].first);
+  return mem;
+};
+
+
+
 // explicit instantiations
 template class FESystem<deal_II_dimension>;
 
diff --git a/deal.II/deal.II/source/fe/fe_values.cc b/deal.II/deal.II/source/fe/fe_values.cc
index 3e02dbb2f1..c93fc08039 100644
--- a/deal.II/deal.II/source/fe/fe_values.cc
+++ b/deal.II/deal.II/source/fe/fe_values.cc
@@ -14,6 +14,7 @@
 
 #include <fe/fe.h>
 #include <fe/fe_values.h>
+#include <base/memory_consumption.h>
 #include <base/quadrature.h>
 #include <grid/tria_iterator.h>
 #include <grid/tria_accessor.h>
@@ -362,6 +363,29 @@ double FEValuesBase<dim>::JxW (const unsigned int i) const
 };
 
 
+
+template <int dim>
+unsigned int
+FEValuesBase<dim>::memory_consumption () const
+{
+  return (MemoryConsumption::memory_consumption (shape_values) +
+	  MemoryConsumption::memory_consumption (shape_gradients) +
+	  MemoryConsumption::memory_consumption (shape_2nd_derivatives) +
+	  MemoryConsumption::memory_consumption (weights) +
+	  MemoryConsumption::memory_consumption (JxW_values) +
+	  MemoryConsumption::memory_consumption (quadrature_points) +
+	  MemoryConsumption::memory_consumption (support_points) +
+	  MemoryConsumption::memory_consumption (jacobi_matrices) +
+	  MemoryConsumption::memory_consumption (jacobi_matrices_grad) +
+	  MemoryConsumption::memory_consumption (shape_values_transform) +
+	  MemoryConsumption::memory_consumption (selected_dataset) +
+	  MemoryConsumption::memory_consumption (jacobi_matrices) +
+	  sizeof(update_flags) +
+	  MemoryConsumption::memory_consumption (present_cell) +
+	  MemoryConsumption::memory_consumption (fe));
+};
+
+
 /*------------------------------- FEValues -------------------------------*/
 
 template <int dim>
@@ -502,6 +526,19 @@ void FEValues<dim>::reinit (const typename DoFHandler<dim>::cell_iterator &cell)
 };
 
 
+
+template <int dim>
+unsigned int
+FEValues<dim>::memory_consumption () const
+{
+  return (FEValuesBase<dim>::memory_consumption () +
+	  MemoryConsumption::memory_consumption (unit_shape_gradients) +
+	  MemoryConsumption::memory_consumption (unit_shape_2nd_derivatives) +
+	  MemoryConsumption::memory_consumption (unit_shape_gradients_transform) +
+	  MemoryConsumption::memory_consumption (unit_quadrature_points));
+};
+
+
 /*------------------------------- FEFaceValuesBase --------------------------*/
 
 
@@ -551,6 +588,24 @@ FEFaceValuesBase<dim>::normal_vector (const unsigned int i) const
 };
 
 
+
+
+template <int dim>
+unsigned int
+FEFaceValuesBase<dim>::memory_consumption () const
+{
+  return (FEValuesBase<dim>::memory_consumption () +
+	  MemoryConsumption::memory_consumption (unit_shape_gradients) +
+	  MemoryConsumption::memory_consumption (unit_shape_2nd_derivatives) +
+	  MemoryConsumption::memory_consumption (unit_shape_gradients_transform) +
+	  MemoryConsumption::memory_consumption (unit_face_quadrature_points) +
+	  MemoryConsumption::memory_consumption (unit_quadrature_points) +
+	  MemoryConsumption::memory_consumption (face_jacobi_determinants) +
+	  MemoryConsumption::memory_consumption (normal_vectors) +
+	  MemoryConsumption::memory_consumption (present_face));
+};
+
+
 /*------------------------------- FEFaceValues -------------------------------*/
 
 
diff --git a/deal.II/deal.II/source/grid/grid_out.all_dimensions.cc b/deal.II/deal.II/source/grid/grid_out.all_dimensions.cc
index 983baaeb9b..aa1aa5088d 100644
--- a/deal.II/deal.II/source/grid/grid_out.all_dimensions.cc
+++ b/deal.II/deal.II/source/grid/grid_out.all_dimensions.cc
@@ -117,8 +117,18 @@ GridOut::parse_output_format (const string &format_name)
 };
 
 
-string GridOut::get_output_format_names () {
+string GridOut::get_output_format_names () 
+{
   return "gnuplot|eps";
 };
 
 
+unsigned int
+GridOut::memory_consumption () const
+{
+  return (sizeof(ucd_flags) +
+	  sizeof(gnuplot_flags) +
+	  sizeof(eps_flags_1) +
+	  sizeof(eps_flags_2) +
+	  sizeof(eps_flags_3));
+};
diff --git a/deal.II/deal.II/source/grid/intergrid_map.cc b/deal.II/deal.II/source/grid/intergrid_map.cc
index 6c20a2bad7..1ade48150a 100644
--- a/deal.II/deal.II/source/grid/intergrid_map.cc
+++ b/deal.II/deal.II/source/grid/intergrid_map.cc
@@ -12,6 +12,7 @@
 //----------------------------  intergrid_map.cc  ---------------------------
 
 
+#include <base/memory_consumption.h>
 #include <grid/tria.h>
 #include <dofs/dof_handler.h>
 #include <grid/tria_accessor.h>
@@ -196,7 +197,17 @@ InterGridMap<GridClass,dim>::get_destination_grid () const
   return *destination_grid;
 };
 
-  
+
+
+template <template <int> class GridClass, int dim>
+unsigned int
+InterGridMap<GridClass,dim>::memory_consumption () const
+{
+  return (MemoryConsumption::memory_consumption (mapping) +
+	  MemoryConsumption::memory_consumption (source_grid) +
+	  MemoryConsumption::memory_consumption (destination_grid));
+};
+
 
   
 // explicit instantiations
diff --git a/deal.II/deal.II/source/grid/persistent_tria.cc b/deal.II/deal.II/source/grid/persistent_tria.cc
index 77194d2a8c..08a05991dd 100644
--- a/deal.II/deal.II/source/grid/persistent_tria.cc
+++ b/deal.II/deal.II/source/grid/persistent_tria.cc
@@ -12,6 +12,7 @@
 //----------------------------  persistent_tria.cc  ---------------------------
 
 
+#include <base/memory_consumption.h>
 #include <grid/persistent_tria.h>
 #include <grid/magic_numbers.h>
 #include <iostream>
@@ -160,6 +161,18 @@ PersistentTriangulation<dim>::read_flags(istream &in)
 }
 
 
+
+template <int dim>
+unsigned int
+PersistentTriangulation<dim>::memory_consumption () const
+{
+  return (Triangulation<dim>::memory_consumption () +
+	  MemoryConsumption::memory_consumption (coarse_grid) +
+	  MemoryConsumption::memory_consumption (refine_flags) +
+	  MemoryConsumption::memory_consumption (coarsen_flags));
+};
+
+
 // explicit instantiations
 template class PersistentTriangulation<deal_II_dimension>;
 
diff --git a/deal.II/deal.II/source/grid/tria.all_dimensions.cc b/deal.II/deal.II/source/grid/tria.all_dimensions.cc
index 44594d5efb..92d641626b 100644
--- a/deal.II/deal.II/source/grid/tria.all_dimensions.cc
+++ b/deal.II/deal.II/source/grid/tria.all_dimensions.cc
@@ -12,6 +12,7 @@
 //----------------------------  tria.all_dimensions.cc  ---------------------------
 
 
+#include <base/memory_consumption.h>
 #include <grid/tria.h>
 #include <grid/tria_levels.h>
 #include <grid/tria_boundary.h>
@@ -177,6 +178,16 @@ void TriangulationLevel<0>::monitor_memory (const unsigned int true_dimension) c
 
 
 
+unsigned int
+TriangulationLevel<0>::memory_consumption () const
+{
+  return (MemoryConsumption::memory_consumption (refine_flags) +
+	  MemoryConsumption::memory_consumption (coarsen_flags) +
+	  MemoryConsumption::memory_consumption (neighbors));
+};
+
+
+
 void TriangulationLevel<1>::reserve_space (const unsigned int new_lines)
 {
   const unsigned int new_size = new_lines +
@@ -257,6 +268,19 @@ void TriangulationLevel<1>::monitor_memory (const unsigned int true_dimension) c
 
 
 
+unsigned int
+TriangulationLevel<1>::memory_consumption () const
+{
+  return (TriangulationLevel<0>::memory_consumption() +
+	  MemoryConsumption::memory_consumption (lines.lines) +
+	  MemoryConsumption::memory_consumption (lines.children) +
+	  MemoryConsumption::memory_consumption (lines.used) +
+	  MemoryConsumption::memory_consumption (lines.user_flags) +
+	  MemoryConsumption::memory_consumption (lines.material_id) +
+	  MemoryConsumption::memory_consumption (lines.user_pointers));
+};
+  
+
 void TriangulationLevel<2>::reserve_space (const unsigned int new_quads)
 {
   const unsigned int new_size = new_quads +
@@ -328,6 +352,20 @@ void TriangulationLevel<2>::monitor_memory (const unsigned int true_dimension) c
 
 
 
+unsigned int
+TriangulationLevel<2>::memory_consumption () const
+{
+  return (TriangulationLevel<1>::memory_consumption() +
+	  MemoryConsumption::memory_consumption (quads.quads) +
+	  MemoryConsumption::memory_consumption (quads.children) +
+	  MemoryConsumption::memory_consumption (quads.used) +
+	  MemoryConsumption::memory_consumption (quads.user_flags) +
+	  MemoryConsumption::memory_consumption (quads.material_id) +
+	  MemoryConsumption::memory_consumption (quads.user_pointers));
+};
+
+
+
 void TriangulationLevel<3>::reserve_space (const unsigned int new_hexes)
 {
   const unsigned int new_size = new_hexes +
@@ -399,6 +437,20 @@ void TriangulationLevel<3>::monitor_memory (const unsigned int true_dimension) c
 
 
 
+unsigned int
+TriangulationLevel<3>::memory_consumption () const
+{
+  return (TriangulationLevel<2>::memory_consumption() +
+	  MemoryConsumption::memory_consumption (hexes.hexes) +
+	  MemoryConsumption::memory_consumption (hexes.children) +
+	  MemoryConsumption::memory_consumption (hexes.used) +
+	  MemoryConsumption::memory_consumption (hexes.user_flags) +
+	  MemoryConsumption::memory_consumption (hexes.material_id) +
+	  MemoryConsumption::memory_consumption (hexes.user_pointers));
+};
+
+
+
 TriaNumberCache<1>::TriaNumberCache () :
 		n_lines (0),
 		n_active_lines (0) 
@@ -408,6 +460,16 @@ TriaNumberCache<1>::TriaNumberCache () :
 
 
 
+unsigned int
+TriaNumberCache<1>::memory_consumption () const
+{
+  return (MemoryConsumption::memory_consumption (n_lines) +
+	  MemoryConsumption::memory_consumption (n_lines_level) +
+	  MemoryConsumption::memory_consumption (n_active_lines) +
+	  MemoryConsumption::memory_consumption (n_active_lines_level));
+};
+
+
 TriaNumberCache<2>::TriaNumberCache () :
 		n_quads (0),
 		n_active_quads (0) 
@@ -417,9 +479,33 @@ TriaNumberCache<2>::TriaNumberCache () :
 
 
 
+unsigned int
+TriaNumberCache<2>::memory_consumption () const
+{
+  return (TriaNumberCache<1>::memory_consumption () +
+	  MemoryConsumption::memory_consumption (n_quads) +
+	  MemoryConsumption::memory_consumption (n_quads_level) +
+	  MemoryConsumption::memory_consumption (n_active_quads) +
+	  MemoryConsumption::memory_consumption (n_active_quads_level));
+};
+
+
+
 TriaNumberCache<3>::TriaNumberCache () :
 		n_hexes (0),
 		n_active_hexes (0) 
 						 // all other fields are
 						 // default constructed
 {};
+
+
+
+unsigned int
+TriaNumberCache<3>::memory_consumption () const
+{
+  return (TriaNumberCache<2>::memory_consumption () +
+	  MemoryConsumption::memory_consumption (n_hexes) +
+	  MemoryConsumption::memory_consumption (n_hexes_level) +
+	  MemoryConsumption::memory_consumption (n_active_hexes) +
+	  MemoryConsumption::memory_consumption (n_active_hexes_level));
+};
diff --git a/deal.II/deal.II/source/grid/tria.cc b/deal.II/deal.II/source/grid/tria.cc
index fd4c96b52b..fc21e14a58 100644
--- a/deal.II/deal.II/source/grid/tria.cc
+++ b/deal.II/deal.II/source/grid/tria.cc
@@ -12,6 +12,7 @@
 //----------------------------  tria.cc  ---------------------------
 
 
+#include <base/memory_consumption.h>
 #include <grid/tria.h>
 #include <grid/tria_levels.h>
 #include <grid/tria_boundary.h>
@@ -7394,6 +7395,27 @@ void Triangulation<dim>::read_bool_vector (const unsigned int  magic_number1,
 };
 
 
+
+template <int dim>
+unsigned int
+Triangulation<dim>::memory_consumption () const 
+{
+  unsigned int mem = 0;
+  mem += MemoryConsumption::memory_consumption(levels);
+  for (unsigned int i=0; i<levels.size(); ++i)
+    mem += MemoryConsumption::memory_consumption (*levels[i]);
+  mem += MemoryConsumption::memory_consumption (vertices);
+  mem += MemoryConsumption::memory_consumption (vertices_used);
+  mem += sizeof(boundary);
+  mem += sizeof(smooth_grid);
+  mem += MemoryConsumption::memory_consumption (number_cache);
+
+  return mem;
+};
+
+  
+
+
 template <int dim>
 void Triangulation<dim>::update_number_cache_lines () 
 {
diff --git a/deal.II/lac/include/lac/block_indices.h b/deal.II/lac/include/lac/block_indices.h
index a48c81800f..6869bb1b4b 100644
--- a/deal.II/lac/include/lac/block_indices.h
+++ b/deal.II/lac/include/lac/block_indices.h
@@ -117,6 +117,13 @@ class BlockIndices
 				      * objects.
 				      */
     void swap (BlockIndices &b);
+
+				     /**
+				      * Determine an estimate for the
+				      * memory consumption (in bytes)
+				      * of this object.
+				      */
+    unsigned int memory_consumption () const;
     
   private:
 				     /**
@@ -272,6 +279,16 @@ BlockIndices::swap (BlockIndices &b)
 
 
 
+inline
+unsigned int
+BlockIndices::memory_consumption () const
+{
+  return (sizeof(*this) + 
+	  start_indices.size() * sizeof(start_indices[0]));
+};
+
+
+
 /* ----------------- global functions ---------------------------- */
 
 
diff --git a/deal.II/lac/include/lac/block_sparse_matrix.h b/deal.II/lac/include/lac/block_sparse_matrix.h
index a1b70e92a2..82bd776c51 100644
--- a/deal.II/lac/include/lac/block_sparse_matrix.h
+++ b/deal.II/lac/include/lac/block_sparse_matrix.h
@@ -437,6 +437,13 @@ class BlockSparseMatrix : public Subscriptor
     const BlockSparsityPattern &
     get_sparsity_pattern () const;
 
+				     /**
+				      * Determine an estimate for the
+				      * memory consumption (in bytes)
+				      * of this object.
+				      */
+    unsigned int memory_consumption () const;
+
 				     /**
 				      * Exception
 				      */
diff --git a/deal.II/lac/include/lac/block_sparse_matrix.templates.h b/deal.II/lac/include/lac/block_sparse_matrix.templates.h
index e7cb56603c..52abe1a3df 100644
--- a/deal.II/lac/include/lac/block_sparse_matrix.templates.h
+++ b/deal.II/lac/include/lac/block_sparse_matrix.templates.h
@@ -14,6 +14,7 @@
 #define __deal2__block_sparse_matrix_templates_h
 
 
+#include <base/memory_consumption.h>
 #include <lac/block_sparse_matrix.h>
 
 
@@ -120,4 +121,17 @@ BlockSparseMatrix<number,rows,columns>::get_sparsity_pattern () const
 
 
 
+template <typename number, int  rows, int columns>
+unsigned int
+BlockSparseMatrix<number,rows,columns>::memory_consumption () const
+{
+  unsigned int mem = sizeof(*this);
+  for (unsigned int r=0; r<rows; ++r)
+    for (unsigned int c=0; c<columns; ++c)
+      mem += MemoryConsumption::memory_consumption(sub_objects[r][c]);
+  return mem;
+};
+
+
+
 #endif // ifdef block_sparse_matrix_templates_h
diff --git a/deal.II/lac/include/lac/block_sparsity_pattern.h b/deal.II/lac/include/lac/block_sparsity_pattern.h
index 029cbbb2a8..bd9655893e 100644
--- a/deal.II/lac/include/lac/block_sparsity_pattern.h
+++ b/deal.II/lac/include/lac/block_sparsity_pattern.h
@@ -310,6 +310,13 @@ class BlockSparsityPattern : public Subscriptor
 				      */
     bool is_compressed () const;
 
+				     /**
+				      * Determine an estimate for the
+				      * memory consumption (in bytes)
+				      * of this object.
+				      */
+    unsigned int memory_consumption () const;
+
 				     /**
 				      * Exception
 				      */
diff --git a/deal.II/lac/include/lac/block_vector.h b/deal.II/lac/include/lac/block_vector.h
index c7fce8a4c4..b9b6b6071b 100644
--- a/deal.II/lac/include/lac/block_vector.h
+++ b/deal.II/lac/include/lac/block_vector.h
@@ -481,6 +481,14 @@ class BlockVector
 				      * file, but not more.
 				      */
     void block_read (istream &in);
+
+				     /**
+				      * Determine an estimate for the
+				      * memory consumption (in bytes)
+				      * of this object.
+				      */
+    unsigned int memory_consumption () const;
+
 				     //@}
 
   protected:
diff --git a/deal.II/lac/include/lac/block_vector.templates.h b/deal.II/lac/include/lac/block_vector.templates.h
index 8af6af75d7..47434977c7 100644
--- a/deal.II/lac/include/lac/block_vector.templates.h
+++ b/deal.II/lac/include/lac/block_vector.templates.h
@@ -14,6 +14,7 @@
 #define __deal2__block_vector_templates_h
 
 
+#include <base/memory_consumption.h>
 #include <lac/block_vector.h>
 #include <cmath>
 #include <algorithm>
@@ -466,6 +467,7 @@ void BlockVector<Number>::print (ostream &out,
 }
 
 
+
 template <typename Number>
 void BlockVector<Number>::block_write (ostream &out) const
 {
@@ -476,6 +478,7 @@ void BlockVector<Number>::block_write (ostream &out) const
 }
 
 
+
 template <typename Number>
 void BlockVector<Number>::block_read (istream &in)
 {
@@ -485,4 +488,20 @@ void BlockVector<Number>::block_read (istream &in)
     }  
 }
 
+
+template <typename Number>
+unsigned int
+BlockVector<Number>::memory_consumption () const
+{
+  unsigned int mem = sizeof(num_blocks);
+  for (unsigned int i=0; i<components.size(); ++i)
+    mem += MemoryConsumption::memory_consumption (components[i]);
+  mem += MemoryConsumption::memory_consumption (block_indices);
+  return mem;
+};
+
+
+
+
+
 #endif
diff --git a/deal.II/lac/include/lac/full_matrix.h b/deal.II/lac/include/lac/full_matrix.h
index b9b23aeecc..63d46318f9 100644
--- a/deal.II/lac/include/lac/full_matrix.h
+++ b/deal.II/lac/include/lac/full_matrix.h
@@ -561,6 +561,13 @@ class FullMatrix : public Subscriptor
 				      */
     void print_formatted (ostream &out,
 			  const unsigned int presicion=3) const;
+    
+				     /**
+				      * Determine an estimate for the
+				      * memory consumption (in bytes)
+				      * of this object.
+				      */
+    unsigned int memory_consumption () const;
 
 				     /**
 				      * Exception
diff --git a/deal.II/lac/include/lac/full_matrix.templates.h b/deal.II/lac/include/lac/full_matrix.templates.h
index 1843378d29..c819b10efb 100644
--- a/deal.II/lac/include/lac/full_matrix.templates.h
+++ b/deal.II/lac/include/lac/full_matrix.templates.h
@@ -1458,4 +1458,14 @@ FullMatrix<number>::least_squares(Vector<number2>& dst, Vector<number2>& src)
   return sqrt(sum);
 }
 
+
+
+template <typename number>
+unsigned int
+FullMatrix<number>::memory_consumption () const
+{
+  return sizeof(*this) + val_size*sizeof(number);
+};
+
+
 #endif
diff --git a/deal.II/lac/include/lac/precondition_block.h b/deal.II/lac/include/lac/precondition_block.h
index 509bab60fa..d8ba3d0e54 100644
--- a/deal.II/lac/include/lac/precondition_block.h
+++ b/deal.II/lac/include/lac/precondition_block.h
@@ -164,6 +164,13 @@ class PreconditionBlock
 				      */
     unsigned int block_size () const;
 
+				     /**
+				      * Determine an estimate for the
+				      * memory consumption (in bytes)
+				      * of this object.
+				      */
+    unsigned int memory_consumption () const;
+
 				     /**
 				      * Determine, whether inverses
 				      * have been computed.
diff --git a/deal.II/lac/include/lac/precondition_block.templates.h b/deal.II/lac/include/lac/precondition_block.templates.h
index 776d1f5ad6..52effedff9 100644
--- a/deal.II/lac/include/lac/precondition_block.templates.h
+++ b/deal.II/lac/include/lac/precondition_block.templates.h
@@ -16,6 +16,7 @@
 
 #include <base/exceptions.h>
 #include <base/logstream.h>
+#include <base/memory_consumption.h>
 #include <lac/precondition_block.h>
 #include <lac/vector.h>
 #include <lac/full_matrix.h>
@@ -197,6 +198,22 @@ void PreconditionBlock<number,inverse_type>::invert_diagblocks()
 }
 
 
+
+template <typename number, typename inverse_type>
+unsigned int
+PreconditionBlock<number,inverse_type>::memory_consumption () const
+{
+  unsigned int mem = sizeof(*this);
+  for (unsigned int i=0; i<var_inverse.size(); ++i)
+    mem += MemoryConsumption::memory_consumption(var_inverse[i]);
+  for (unsigned int i=0; i<var_diagonal.size(); ++i)
+    mem += MemoryConsumption::memory_consumption(var_diagonal[i]);
+  return mem;
+};
+
+
+
+
 /*--------------------- PreconditionBlockJacobi -----------------------*/
 
 
diff --git a/deal.II/lac/include/lac/sparse_ilu.h b/deal.II/lac/include/lac/sparse_ilu.h
index ef14099b0c..e87efffec7 100644
--- a/deal.II/lac/include/lac/sparse_ilu.h
+++ b/deal.II/lac/include/lac/sparse_ilu.h
@@ -195,6 +195,13 @@ class SparseILU : protected SparseMatrix<number>
     void vmult (Vector<somenumber>       &dst,
 		const Vector<somenumber> &src) const;
 
+				     /**
+				      * Determine an estimate for the
+				      * memory consumption (in bytes)
+				      * of this object.
+				      */
+    unsigned int memory_consumption () const;
+
 				     /**
 				      * Exception
 				      */
diff --git a/deal.II/lac/include/lac/sparse_ilu.templates.h b/deal.II/lac/include/lac/sparse_ilu.templates.h
index 15a1f059f9..e32255de43 100644
--- a/deal.II/lac/include/lac/sparse_ilu.templates.h
+++ b/deal.II/lac/include/lac/sparse_ilu.templates.h
@@ -339,6 +339,16 @@ void SparseILU<number>::apply_decomposition (Vector<somenumber>       &dst,
 };
 
 
+
+template <typename number>
+unsigned int
+SparseILU<number>::memory_consumption () const
+{
+  return SparseMatrix<number>::memory_consumption ();
+};
+
+
+
 /*----------------------------   sparse_ilu.templates.h     ---------------------------*/
 
 #endif
diff --git a/deal.II/lac/include/lac/sparse_matrix.h b/deal.II/lac/include/lac/sparse_matrix.h
index 57902399df..ffd0d5f5ca 100644
--- a/deal.II/lac/include/lac/sparse_matrix.h
+++ b/deal.II/lac/include/lac/sparse_matrix.h
@@ -692,6 +692,13 @@ class SparseMatrix : public Subscriptor
 			  const unsigned int  width       = 0,
 			  const char         *zero_string = " ",
 			  const double        denominator = 1.) const;
+
+				     /**
+				      * Determine an estimate for the
+				      * memory consumption (in bytes)
+				      * of this object.
+				      */
+    unsigned int memory_consumption () const;
     
 				     /**
 				      * Exception
diff --git a/deal.II/lac/include/lac/sparse_matrix.templates.h b/deal.II/lac/include/lac/sparse_matrix.templates.h
index ced79b2c33..c1db80dc55 100644
--- a/deal.II/lac/include/lac/sparse_matrix.templates.h
+++ b/deal.II/lac/include/lac/sparse_matrix.templates.h
@@ -1004,4 +1004,14 @@ void SparseMatrix<number>::print_formatted (ostream &out,
 //  out.setf (0, ios::floatfield);                 // reset output format
 };
 
+
+
+template <typename number>
+unsigned int
+SparseMatrix<number>::memory_consumption () const
+{
+  return sizeof(*this) + max_len*sizeof(number);
+};
+
+
 #endif
diff --git a/deal.II/lac/include/lac/sparse_vanka.h b/deal.II/lac/include/lac/sparse_vanka.h
index 5213b4102a..af1907743c 100644
--- a/deal.II/lac/include/lac/sparse_vanka.h
+++ b/deal.II/lac/include/lac/sparse_vanka.h
@@ -264,6 +264,13 @@ class SparseVanka
     void apply_preconditioner (Vector<number2>       &dst,
 			       const Vector<number2> &src,
 			       const vector<bool>    *dof_mask = 0) const;    
+
+				     /**
+				      * Determine an estimate for the
+				      * memory consumption (in bytes)
+				      * of this object.
+				      */
+    unsigned int memory_consumption () const;
     
   private:
 				     /**
@@ -519,6 +526,13 @@ class SparseBlockVanka : public SparseVanka<number>
     void vmult (Vector<number2>       &dst,
 		     const Vector<number2> &src) const;
     
+				     /**
+				      * Determine an estimate for the
+				      * memory consumption (in bytes)
+				      * of this object.
+				      */
+    unsigned int memory_consumption () const;
+
   private:
 				     /**
 				      * Store the number of blocks.
diff --git a/deal.II/lac/include/lac/sparse_vanka.templates.h b/deal.II/lac/include/lac/sparse_vanka.templates.h
index 8386d6da6d..ff6f398ff6 100644
--- a/deal.II/lac/include/lac/sparse_vanka.templates.h
+++ b/deal.II/lac/include/lac/sparse_vanka.templates.h
@@ -14,6 +14,7 @@
 #define __deal2__sparse_vanka_templates_h
 
 
+#include <base/memory_consumption.h>
 #include <lac/sparse_vanka.h>
 #include <lac/full_matrix.h>
 #include <lac/sparse_matrix.h>
@@ -363,6 +364,22 @@ SparseVanka<number>::apply_preconditioner (Vector<number2>       &dst,
 };
 
 
+
+template <typename number>
+unsigned int
+SparseVanka<number>::memory_consumption () const
+{
+  unsigned int mem = (sizeof(*this) +
+		      MemoryConsumption::memory_consumption (selected));
+  for (unsigned int i=0; i<inverses.size(); ++i)
+    mem += MemoryConsumption::memory_consumption (*inverses[i]);
+  
+  return mem;
+};
+
+
+
+
 template <typename number>
 SparseBlockVanka<number>::SparseBlockVanka (const SparseMatrix<number> &M,
 					    const vector<bool>         &selected,
@@ -576,4 +593,18 @@ void SparseBlockVanka<number>::vmult (Vector<number2>       &dst,
     }
 }
 
+
+
+template <typename number>
+unsigned int
+SparseBlockVanka<number>::memory_consumption () const
+{
+  unsigned int mem = SparseVanka<number>::memory_consumption();
+  for (unsigned int i=0; i<dof_masks.size(); ++i)
+    mem += MemoryConsumption::memory_consumption (dof_masks[i]);
+  return mem;
+};
+
+	  
+
 #endif
diff --git a/deal.II/lac/include/lac/sparsity_pattern.h b/deal.II/lac/include/lac/sparsity_pattern.h
index 9e2165b58b..fbf44987ce 100644
--- a/deal.II/lac/include/lac/sparsity_pattern.h
+++ b/deal.II/lac/include/lac/sparsity_pattern.h
@@ -499,6 +499,12 @@ class SparsityPattern : public Subscriptor
 				      */
     const unsigned int * get_column_numbers () const;
 
+				     /**
+				      * Determine an estimate for the
+				      * memory consumption (in bytes)
+				      * of this object.
+				      */
+    unsigned int memory_consumption () const;
 
 				     /**
 				      * Exception
diff --git a/deal.II/lac/include/lac/swappable_vector.h b/deal.II/lac/include/lac/swappable_vector.h
index 11bfd2d650..d8e172ed51 100644
--- a/deal.II/lac/include/lac/swappable_vector.h
+++ b/deal.II/lac/include/lac/swappable_vector.h
@@ -221,6 +221,13 @@ class SwappableVector : public Vector<number>
 				      */
     const string & get_filename () const;
    
+				     /**
+				      * Determine an estimate for the
+				      * memory consumption (in bytes)
+				      * of this object.
+				      */
+    unsigned int memory_consumption () const;
+
 				     /**
 				      * Exception.
 				      */ 
diff --git a/deal.II/lac/include/lac/swappable_vector.templates.h b/deal.II/lac/include/lac/swappable_vector.templates.h
index 48a5b760e1..94f14e652b 100644
--- a/deal.II/lac/include/lac/swappable_vector.templates.h
+++ b/deal.II/lac/include/lac/swappable_vector.templates.h
@@ -14,6 +14,7 @@
 #define __deal2__swappable_vector_templates_h
 
 
+#include <base/memory_consumption.h>
 #include <lac/swappable_vector.h>
 #include <fstream>
 #include <iostream>
@@ -262,5 +263,17 @@ SwappableVector<number>::get_filename () const
 
 
 
+template <typename number>
+unsigned int
+SwappableVector<number>::memory_consumption () const
+{
+  return (MemoryConsumption::memory_consumption (filename) +
+	  sizeof(lock) +
+	  MemoryConsumption::memory_consumption (data_is_preloaded) +
+	  Vector<number>::memory_consumption ());
+};
+
+
+
 
 #endif // __deal2__swappable_vector_templates_h
diff --git a/deal.II/lac/include/lac/vector.h b/deal.II/lac/include/lac/vector.h
index 12212d1f33..dc8f79a22e 100644
--- a/deal.II/lac/include/lac/vector.h
+++ b/deal.II/lac/include/lac/vector.h
@@ -448,6 +448,13 @@ class Vector {
 				      * file, but not more.
 				      */
     void block_read (istream &in);
+
+				     /**
+				      * Determine an estimate for the
+				      * memory consumption (in bytes)
+				      * of this object.
+				      */
+    unsigned int memory_consumption () const;
 				     //@}
 
 				     /**
diff --git a/deal.II/lac/include/lac/vector.templates.h b/deal.II/lac/include/lac/vector.templates.h
index fa171fdd58..4ef8a4a25c 100644
--- a/deal.II/lac/include/lac/vector.templates.h
+++ b/deal.II/lac/include/lac/vector.templates.h
@@ -667,4 +667,14 @@ void Vector<Number>::block_read (istream &in)
   AssertThrow (in, ExcIO());
 }
 
+
+
+template <typename Number>
+unsigned int
+Vector<Number>::memory_consumption () const
+{
+  return sizeof(*this) + (maxdim * sizeof(Number));
+};
+
+
 #endif
diff --git a/deal.II/lac/source/block_sparsity_pattern.cc b/deal.II/lac/source/block_sparsity_pattern.cc
index 452e12e1e1..2ffe42ef26 100644
--- a/deal.II/lac/source/block_sparsity_pattern.cc
+++ b/deal.II/lac/source/block_sparsity_pattern.cc
@@ -11,6 +11,7 @@
 //
 //----------------------------  block_block_sparsity_pattern.cc  ---------------------------
 
+#include <base/memory_consumption.h>
 #include <lac/block_sparsity_pattern.h>
 
 
@@ -214,3 +215,19 @@ BlockSparsityPattern::is_compressed () const
   return true;
 };
 
+
+unsigned int
+BlockSparsityPattern::memory_consumption () const
+{
+  unsigned int mem = 0;
+  mem += (MemoryConsumption::memory_consumption (rows) +
+	  MemoryConsumption::memory_consumption (columns) +
+	  MemoryConsumption::memory_consumption (sub_objects) +
+	  MemoryConsumption::memory_consumption (row_indices) +
+	  MemoryConsumption::memory_consumption (column_indices));
+  for (unsigned int r=0; r<rows; ++r)
+    for (unsigned int c=0; c<columns; ++c)
+      mem += MemoryConsumption::memory_consumption (*sub_objects[r][c]);
+  
+  return mem;
+};
diff --git a/deal.II/lac/source/sparsity_pattern.cc b/deal.II/lac/source/sparsity_pattern.cc
index 27a1e29d69..81bb2999ee 100644
--- a/deal.II/lac/source/sparsity_pattern.cc
+++ b/deal.II/lac/source/sparsity_pattern.cc
@@ -611,3 +611,12 @@ SparsityPattern::bandwidth () const
   return b;
 };
 
+
+
+unsigned int
+SparsityPattern::memory_consumption () const
+{
+  return (sizeof(*this) +
+	  max_dim * sizeof(unsigned int) +
+	  max_vec_len * sizeof(unsigned int));
+};
-- 
2.39.5