You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by ga...@apache.org on 2007/08/21 10:50:51 UTC

svn commit: r568025 - in /xerces/c/branches/xerces-2.7/src/xercesc/dom/impl: DOMDocumentImpl.cpp DOMDocumentImpl.hpp

Author: gareth
Date: Tue Aug 21 01:50:50 2007
New Revision: 568025

URL: http://svn.apache.org/viewvc?rev=568025&view=rev
Log:
Exponential growth for DOM heap. Thanks to Boris Kolpackov

Modified:
    xerces/c/branches/xerces-2.7/src/xercesc/dom/impl/DOMDocumentImpl.cpp
    xerces/c/branches/xerces-2.7/src/xercesc/dom/impl/DOMDocumentImpl.hpp

Modified: xerces/c/branches/xerces-2.7/src/xercesc/dom/impl/DOMDocumentImpl.cpp
URL: http://svn.apache.org/viewvc/xerces/c/branches/xerces-2.7/src/xercesc/dom/impl/DOMDocumentImpl.cpp?rev=568025&r1=568024&r2=568025&view=diff
==============================================================================
--- xerces/c/branches/xerces-2.7/src/xercesc/dom/impl/DOMDocumentImpl.cpp (original)
+++ xerces/c/branches/xerces-2.7/src/xercesc/dom/impl/DOMDocumentImpl.cpp Tue Aug 21 01:50:50 2007
@@ -49,6 +49,13 @@
 
 XERCES_CPP_NAMESPACE_BEGIN
 
+// The chunk size to allocate from the system allocator.
+static const XMLSize_t kInitialHeapAllocSize =  0x4000;
+static const XMLSize_t kMaxHeapAllocSize     = 020000;
+static const XMLSize_t kMaxSubAllocationSize =  0x1000;  // Any request for more bytes
+                                                         // than this will be handled by
+                                                         // allocating directly with system.
+
 
 //
 //   Constructors.   Warning - be very careful with the ordering of initialization
@@ -75,6 +82,7 @@
       fCurrentBlock(0),      
       fFreePtr(0),
       fFreeBytesRemaining(0),
+      fHeapAllocSize(kInitialHeapAllocSize),
       fRecycleNodePtr(0),
       fRecycleBufferPtr(0),
       fNodeListPool(0),
@@ -111,6 +119,7 @@
       fCurrentBlock(0),      
       fFreePtr(0),
       fFreeBytesRemaining(0),
+      fHeapAllocSize(kInitialHeapAllocSize),
       fRecycleNodePtr(0),
       fRecycleBufferPtr(0),
       fNodeListPool(0),
@@ -798,13 +807,6 @@
     else return this->fNamePool->getPooledString(src);
 }
 
-static const int kHeapAllocSize = 0x10000;    // The chunk size to allocate from the
-                                              //   system allocator.
-
-static const size_t kMaxSubAllocationSize = 4096;  // Any request for more bytes
-                                                   //  than this will be handled by
-                                                   //  allocating directly with system.
-
 void *         DOMDocumentImpl::allocate(size_t amount)
 {	
 	//	Align the request size so that suballocated blocks
@@ -853,12 +855,15 @@
 
         // Get a new block from the system allocator.
         void* newBlock;
-        newBlock = fMemoryManager->allocate(kHeapAllocSize * sizeof(char)); //new char[kHeapAllocSize];
+        newBlock = fMemoryManager->allocate(fHeapAllocSize * sizeof(char)); //new char[kHeapAllocSize];
         
         *(void **)newBlock = fCurrentBlock;
         fCurrentBlock = newBlock;
         fFreePtr = (char *)newBlock + sizeOfHeader;
-        fFreeBytesRemaining = kHeapAllocSize - sizeOfHeader;
+        fFreeBytesRemaining = fHeapAllocSize - sizeOfHeader;
+
+        if(fHeapAllocSize<kMaxHeapAllocSize)
+            fHeapAllocSize*=2;
     }
 
 	//	Subdivide the request off current block

Modified: xerces/c/branches/xerces-2.7/src/xercesc/dom/impl/DOMDocumentImpl.hpp
URL: http://svn.apache.org/viewvc/xerces/c/branches/xerces-2.7/src/xercesc/dom/impl/DOMDocumentImpl.hpp?rev=568025&r1=568024&r2=568025&view=diff
==============================================================================
--- xerces/c/branches/xerces-2.7/src/xercesc/dom/impl/DOMDocumentImpl.hpp (original)
+++ xerces/c/branches/xerces-2.7/src/xercesc/dom/impl/DOMDocumentImpl.hpp Tue Aug 21 01:50:50 2007
@@ -327,7 +327,8 @@
     //
     void*                 fCurrentBlock;
     char*                 fFreePtr;
-    XMLSize_t             fFreeBytesRemaining;
+    XMLSize_t             fFreeBytesRemaining,
+                          fHeapAllocSize;
 
     // To recycle the DOMNode pointer
     RefArrayOf<DOMNodePtr>* fRecycleNodePtr;



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org