]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Report how much memory was requested when we fail allocating that much. 8959/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Thu, 24 Oct 2019 20:19:54 +0000 (14:19 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Thu, 24 Oct 2019 20:19:54 +0000 (14:19 -0600)
include/deal.II/base/exceptions.h
source/base/utilities.cc

index b95201b618e489af6b7d8af146689989607b23cd..0833fa83c57e1d17e408025f910904915f483e3e 100644 (file)
@@ -690,14 +690,18 @@ namespace StandardExceptions
   /**
    * Trying to allocate a new object failed due to lack of free memory.
    */
-  DeclExceptionMsg(ExcOutOfMemory,
-                   "Your program tried to allocate some memory but this "
-                   "allocation failed. Typically, this either means that "
-                   "you simply do not have enough memory in your system, "
-                   "or that you are (erroneously) trying to allocate "
-                   "a chunk of memory that is simply beyond all reasonable "
-                   "size, for example because the size of the object has "
-                   "been computed incorrectly.");
+  DeclException1(ExcOutOfMemory,
+                 std::size_t,
+                 "Your program tried to allocate some memory but this "
+                 "allocation failed. Typically, this either means that "
+                 "you simply do not have enough memory in your system, "
+                 "or that you are (erroneously) trying to allocate "
+                 "a chunk of memory that is simply beyond all reasonable "
+                 "size, for example because the size of the object has "
+                 "been computed incorrectly."
+                 "\n\n"
+                 "In the current case, the request was for "
+                   << arg1 << " bytes.");
 
   /**
    * A memory handler reached a point where all allocated objects should have
index 2ad59b00008e980f5d102cb392fd842de38bc274..c0dd4e532bdeccb063dbc73cfa88bdfc7d18b618 100644 (file)
@@ -1036,14 +1036,14 @@ namespace Utilities
 #ifndef DEAL_II_MSVC
       const int ierr = ::posix_memalign(memptr, alignment, size);
 
-      AssertThrow(ierr == 0, ExcOutOfMemory());
-      AssertThrow(*memptr != nullptr, ExcOutOfMemory());
+      AssertThrow(ierr == 0, ExcOutOfMemory(size));
+      AssertThrow(*memptr != nullptr, ExcOutOfMemory(size));
 #else
       // Windows does not appear to have posix_memalign. just use the
       // regular malloc in that case
       *memptr = malloc(size);
       (void)alignment;
-      AssertThrow(*memptr != 0, ExcOutOfMemory());
+      AssertThrow(*memptr != 0, ExcOutOfMemory(size));
 #endif
     }
 

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.