]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Improve the TecplotFlags memory estimate.
authorDavid Wells <drwells@vt.edu>
Sun, 31 May 2015 22:11:39 +0000 (18:11 -0400)
committerDavid Wells <drwells@vt.edu>
Mon, 1 Jun 2015 02:25:14 +0000 (22:25 -0400)
include/deal.II/base/data_out_base.h
include/deal.II/base/memory_consumption.h
source/base/data_out_base.cc

index 4db99878126067336743cba3e8a70bce85ed2e43..6f3d3c51370f8dd35a93ef260ec85c91e6165500 100644 (file)
@@ -910,8 +910,7 @@ namespace DataOutBase
 
     /**
      * Return an estimate for the memory consumption, in bytes, of this
-     * object. This is not exact (but will usually be close) because calculating
-     * the memory usage of trees (e.g., <tt>std::map</tt>) is difficult.
+     * object.
      */
     std::size_t memory_consumption () const;
   };
index 1185c11b975b84939a9f5904f25f667a237f39d2..166d03f32b651610aec0ebf96c1187b374098cbe 100644 (file)
@@ -170,6 +170,14 @@ namespace MemoryConsumption
   inline
   std::size_t memory_consumption (const long double);
 
+  /**
+   * Determine the amount of memory consumed by a C-style string. The returned
+   * value does not include the size of the pointer. This function only measures
+   * up to (and including) the NUL byte; the underlying buffer may be larger.
+   */
+  inline
+  std::size_t memory_consumption (const char *string);
+
   /**
    * Determine the amount of memory in bytes consumed by a
    * <tt>std::complex</tt> variable.
@@ -441,6 +449,21 @@ namespace MemoryConsumption
 
 
 
+  inline
+  std::size_t memory_consumption (const char *string)
+  {
+    if (string == NULL)
+      {
+        return 0;
+      }
+    else
+      {
+        return /*Don't forget about the NUL! :]*/ sizeof(char) + strlen(string);
+      }
+  }
+
+
+
   template <typename T>
   inline
   std::size_t memory_consumption (const std::complex<T> &)
index b7622f90fd81f789333feaa804018b6b6dc74255..880cda09c4fd0ace5342d844e6746c5778666f6b 100644 (file)
@@ -2306,9 +2306,9 @@ namespace DataOutBase
   std::size_t
   TecplotFlags::memory_consumption () const
   {
-    // only simple data elements, so
-    // use sizeof operator
-    return sizeof (*this);
+    return sizeof(*this)
+           + MemoryConsumption::memory_consumption(tecplot_binary_file_name)
+           + MemoryConsumption::memory_consumption(zone_name);
   }
 
 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.