Index: /trunk/Mars/mcore/MemoryManager.h
===================================================================
--- /trunk/Mars/mcore/MemoryManager.h	(revision 17249)
+++ /trunk/Mars/mcore/MemoryManager.h	(revision 17250)
@@ -21,9 +21,7 @@
 
 public:
-    MemoryStock(size_t chunk, size_t max) : fChunkSize(chunk), fMaxMemory(max),
+    MemoryStock(size_t chunk, size_t max) : fChunkSize(chunk), fMaxMemory(max<chunk?chunk:max),
         fInUse(0), fAllocated(0), fMaxInUse(0)
     {
-        if (chunk>max)
-            throw std::runtime_error("Size mismatch: Size of a single chunk exceeds maximum size of memory");
     }
 
@@ -138,17 +136,19 @@
 
     size_t getChunkSize() const { return fMemoryStock->fChunkSize; }
-    void   setChunkSize(const size_t size)
+    bool   setChunkSize(const size_t size)
     {
-        if (getInUse() != 0)
+#ifdef __EXCEPTIONS
+        if (getInUse())
             throw std::runtime_error("Cannot change the chunk size while there is memory in use");
+        if (getMaxMemory()<size)
+            throw std::runtime_error("Chunk size("+to_string(size)+") larger thann allowed memory ("+to_string(getMaxMemory())+")");
+#else
+        if (getInUse() || getMaxMemory()<size)
+            return false;
 
-        if (getMaxMemory() < size)
-        {
-            std::ostringstream str;
-            str << "Chunk size(" << size << ") larger thank allowed memory(" << getMaxMemory() << "). Cannot allocate a single chunk.";
-            throw std::runtime_error(str.str());
-        }
         fMemoryStock->fChunkSize = size;
+        return true;
     }
+
     size_t getMaxMemory() const { return fMemoryStock->fMaxMemory; }
     size_t getInUse() const { return fMemoryStock->fInUse; }
