You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by bo...@apache.org on 2008/09/15 13:05:37 UTC
svn commit: r695427 - in /xerces/c/trunk/src/xercesc:
dom/impl/DOMDocumentImpl.cpp util/PlatformUtils.cpp util/PlatformUtils.hpp
util/XMLInitializer.hpp
Author: borisk
Date: Mon Sep 15 04:05:36 2008
New Revision: 695427
URL: http://svn.apache.org/viewvc?rev=695427&view=rev
Log:
Allow changing global DOMDocument heap parameters via overloaded Initialize()
Modified:
xerces/c/trunk/src/xercesc/dom/impl/DOMDocumentImpl.cpp
xerces/c/trunk/src/xercesc/util/PlatformUtils.cpp
xerces/c/trunk/src/xercesc/util/PlatformUtils.hpp
xerces/c/trunk/src/xercesc/util/XMLInitializer.hpp
Modified: xerces/c/trunk/src/xercesc/dom/impl/DOMDocumentImpl.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/dom/impl/DOMDocumentImpl.cpp?rev=695427&r1=695426&r2=695427&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/dom/impl/DOMDocumentImpl.cpp (original)
+++ xerces/c/trunk/src/xercesc/dom/impl/DOMDocumentImpl.cpp Mon Sep 15 04:05:36 2008
@@ -47,16 +47,26 @@
#include <xercesc/dom/DOMImplementation.hpp>
#include <xercesc/framework/MemoryManager.hpp>
#include <xercesc/util/OutOfMemoryException.hpp>
+#include <xercesc/util/XMLInitializer.hpp>
#include <xercesc/util/Janitor.hpp>
XERCES_CPP_NAMESPACE_BEGIN
// The chunk size to allocate from the system allocator.
-static const XMLSize_t kInitialHeapAllocSize = 0x4000;
-static const XMLSize_t kMaxHeapAllocSize = 0x80000;
-static const XMLSize_t kMaxSubAllocationSize = 0x0100; // Any request for more bytes
- // than this will be handled by
- // allocating directly with system.
+static XMLSize_t kInitialHeapAllocSize = 0x4000;
+static XMLSize_t kMaxHeapAllocSize = 0x80000;
+static XMLSize_t kMaxSubAllocationSize = 0x0100; // Any request for more bytes
+ // than this will be handled by
+ // allocating directly with system.
+
+void XMLInitializer::initializeDOMHeap (XMLSize_t initialHeapAllocSize,
+ XMLSize_t maxHeapAllocSize,
+ XMLSize_t maxSubAllocationSize)
+{
+ kInitialHeapAllocSize = initialHeapAllocSize;
+ kMaxHeapAllocSize = maxHeapAllocSize;
+ kMaxSubAllocationSize = maxSubAllocationSize;
+}
//
// Constructors. Warning - be very careful with the ordering of initialization
Modified: xerces/c/trunk/src/xercesc/util/PlatformUtils.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/util/PlatformUtils.cpp?rev=695427&r1=695426&r2=695427&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/PlatformUtils.cpp (original)
+++ xerces/c/trunk/src/xercesc/util/PlatformUtils.cpp Mon Sep 15 04:05:36 2008
@@ -279,6 +279,23 @@
XMLInitializer::initializeStaticData();
}
+void XMLPlatformUtils::Initialize(XMLSize_t initialDOMHeapAllocSize
+ , XMLSize_t maxDOMHeapAllocSize
+ , XMLSize_t maxDOMSubAllocationSize
+ , const char* const locale
+ , const char* const nlsHome
+ , PanicHandler* const panicHandler
+ , MemoryManager* const memoryManager)
+{
+ Initialize (locale, nlsHome, panicHandler, memoryManager);
+
+ // Don't change the parameters unless it is the first time.
+ //
+ if (gInitFlag == 1)
+ XMLInitializer::initializeDOMHeap(initialDOMHeapAllocSize,
+ maxDOMHeapAllocSize,
+ maxDOMSubAllocationSize);
+}
void XMLPlatformUtils::Terminate()
{
Modified: xerces/c/trunk/src/xercesc/util/PlatformUtils.hpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/util/PlatformUtils.hpp?rev=695427&r1=695426&r2=695427&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/PlatformUtils.hpp (original)
+++ xerces/c/trunk/src/xercesc/util/PlatformUtils.hpp Mon Sep 15 04:05:36 2008
@@ -136,15 +136,17 @@
//@}
- /** @name Initialization amd Panic methods */
+ /** @name Initialization and Panic methods */
//@{
/** Perform per-process parser initialization
*
* Initialization <b>must</b> be called first in any client code.
*
+ * @param locale The locale to use for messages.
+ *
* The locale is set iff the Initialize() is invoked for the very first time,
- * to ensure that each and every message loaders, in the process space, share
+ * to ensure that each and every message loader, in the process space, share
* the same locale.
*
* All subsequent invocations of Initialize(), with a different locale, have
@@ -156,24 +158,80 @@
*
* The default locale is "en_US".
*
- * nlsHome: user specified location where MsgLoader retrieves error message files.
- * the discussion above with regard to locale, applies to this nlsHome
- * as well.
- *
- * panicHandler: application's panic handler, application owns this handler.
- * Application shall make sure that the plugged panic handler persists
- * through the call to XMLPlatformUtils::terminate().
- *
- * memoryManager: plugged-in memory manager which is owned by user
- * applications. Applications must make sure that the
- * plugged-in memory manager persist through the call to
- * XMLPlatformUtils::terminate()
+ * @param nlsHome User specified location where MsgLoader retrieves error message files.
+ * the discussion above with regard to locale, applies to nlsHome as well.
+ *
+ * @param panicHandler Application's panic handler, application owns this handler.
+ * Application shall make sure that the plugged panic handler persists
+ * through the call to XMLPlatformUtils::Terminate().
+ *
+ * @param memoryManager Plugged-in memory manager which is owned by the
+ * application. Applications must make sure that the
+ * plugged-in memory manager persist through the call to
+ * XMLPlatformUtils::Terminate()
*/
static void Initialize(const char* const locale = XMLUni::fgXercescDefaultLocale
, const char* const nlsHome = 0
, PanicHandler* const panicHandler = 0
, MemoryManager* const memoryManager = 0);
+ /** Perform per-process parser initialization
+ *
+ * Initialization <b>must</b> be called first in any client code.
+ *
+ * @param initialDOMHeapAllocSize The size of the first memory block
+ * allocated by the DOMDocument heap. Note that changing this parameter
+ * may result in poor performance and/or excessive memory usage. For
+ * the default value refer to dom/impl/DOMDocumentImpl.cpp.
+ *
+ * @param maxDOMHeapAllocSize The maximum size of the memory block
+ * allocated by the DOMDocument heap. As the document grows, the
+ * allocated by the heap memory blocks grow from initialDOMHeapAllocSize
+ * to maxDOMHeapAllocSize. Note that changing this parameter may result
+ * in poor performance and/or excessive memory usage. For the default
+ * value refer to dom/impl/DOMDocumentImpl.cpp.
+ *
+ * @param maxDOMSubAllocationSize The maximum size of the memory block
+ * requested that is handled by the DOMDocument heap. A request for a
+ * larger block is handled directly by the memory manager. Note that
+ * changing this parameter may result in poor performance and/or
+ * excessive memory usage. For the default value refer to
+ * dom/impl/DOMDocumentImpl.cpp.
+ *
+ * @param locale The locale to use for messages.
+ *
+ * The locale is set iff the Initialize() is invoked for the very first time,
+ * to ensure that each and every message loader, in the process space, share
+ * the same locale.
+ *
+ * All subsequent invocations of Initialize(), with a different locale, have
+ * no effect on the message loaders, either instantiated, or to be instantiated.
+ *
+ * To set to a different locale, client application needs to Terminate() (or
+ * multiple Terminate() in the case where multiple Initialize() have been invoked
+ * before), followed by Initialize(new_locale).
+ *
+ * The default locale is "en_US".
+ *
+ * @param nlsHome User specified location where MsgLoader retrieves error message files.
+ * the discussion above with regard to locale, applies to nlsHome as well.
+ *
+ * @param panicHandler Application's panic handler, application owns this handler.
+ * Application shall make sure that the plugged panic handler persists
+ * through the call to XMLPlatformUtils::Terminate().
+ *
+ * @param memoryManager Plugged-in memory manager which is owned by the
+ * application. Applications must make sure that the plugged-in memory
+ * manager persist through the call to XMLPlatformUtils::Terminate()
+ */
+ static void Initialize(XMLSize_t initialDOMHeapAllocSize
+ , XMLSize_t maxDOMHeapAllocSize
+ , XMLSize_t maxDOMSubAllocationSize
+ , const char* const locale = XMLUni::fgXercescDefaultLocale
+ , const char* const nlsHome = 0
+ , PanicHandler* const panicHandler = 0
+ , MemoryManager* const memoryManager = 0);
+
/** Perform per-process parser termination
*
* The termination call is currently optional, to aid those dynamically
Modified: xerces/c/trunk/src/xercesc/util/XMLInitializer.hpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/util/XMLInitializer.hpp?rev=695427&r1=695426&r2=695427&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/XMLInitializer.hpp (original)
+++ xerces/c/trunk/src/xercesc/util/XMLInitializer.hpp Mon Sep 15 04:05:36 2008
@@ -142,6 +142,13 @@
static void terminateDOMDocumentTypeImpl();
static void terminateDOMNodeListImpl();
static void terminateDOMNormalizer();
+
+ //
+ // Extra initialization.
+ //
+ static void initializeDOMHeap (XMLSize_t initialHeapAllocSize,
+ XMLSize_t maxHeapAllocSize,
+ XMLSize_t maxSubAllocationSize);
};
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org