Author: amassari
Date: Mon Oct 27 09:02:26 2008
New Revision: 708224
URL: http://svn.apache.org/viewvc?rev=708224&view=rev
Log:
Reduced memory usage by recycling the ValueStore objects after they went out of
scope
Modified:
xerces/c/trunk/src/xercesc/validators/schema/identity/FieldValueMap.cpp
xerces/c/trunk/src/xercesc/validators/schema/identity/FieldValueMap.hpp
xerces/c/trunk/src/xercesc/validators/schema/identity/ValueStore.cpp
xerces/c/trunk/src/xercesc/validators/schema/identity/ValueStore.hpp
xerces/c/trunk/src/xercesc/validators/schema/identity/ValueStoreCache.cpp
xerces/c/trunk/src/xercesc/validators/schema/identity/ValueStoreCache.hpp
Modified:
xerces/c/trunk/src/xercesc/validators/schema/identity/FieldValueMap.cpp
URL:
http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/validators/schema/identity/FieldValueMap.cpp?rev=708224&r1=708223&r2=708224&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/validators/schema/identity/FieldValueMap.cpp
(original)
+++ xerces/c/trunk/src/xercesc/validators/schema/identity/FieldValueMap.cpp Mon
Oct 27 09:02:26 2008
@@ -109,6 +109,16 @@
return false;
}
+void FieldValueMap::clear()
+{
+ if(fFields)
+ fFields->removeAllElements();
+ if(fValidators)
+ fValidators->removeAllElements();
+ if(fValues)
+ fValues->removeAllElements();
+}
+
XERCES_CPP_NAMESPACE_END
/**
Modified:
xerces/c/trunk/src/xercesc/validators/schema/identity/FieldValueMap.hpp
URL:
http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/validators/schema/identity/FieldValueMap.hpp?rev=708224&r1=708223&r2=708224&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/validators/schema/identity/FieldValueMap.hpp
(original)
+++ xerces/c/trunk/src/xercesc/validators/schema/identity/FieldValueMap.hpp Mon
Oct 27 09:02:26 2008
@@ -73,6 +73,7 @@
// -----------------------------------------------------------------------
XMLSize_t size() const;
bool indexOf(const IC_Field* const key, XMLSize_t& location) const;
+ void clear();
private:
// -----------------------------------------------------------------------
Modified: xerces/c/trunk/src/xercesc/validators/schema/identity/ValueStore.cpp
URL:
http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/validators/schema/identity/ValueStore.cpp?rev=708224&r1=708223&r2=708224&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/validators/schema/identity/ValueStore.cpp
(original)
+++ xerces/c/trunk/src/xercesc/validators/schema/identity/ValueStore.cpp Mon
Oct 27 09:02:26 2008
@@ -44,7 +44,6 @@
, fIdentityConstraint(ic)
, fValues(manager)
, fValueTuples(0)
- , fKeyValueStore(0)
, fScanner(scanner)
, fMemoryManager(manager)
{
@@ -235,6 +234,13 @@
return false;
}
+void ValueStore::clear()
+{
+ fValuesCount=0;
+ fValues.clear();
+ if(fValueTuples)
+ fValueTuples->removeAllElements();
+}
// ---------------------------------------------------------------------------
// ValueStore: Document handling methods
@@ -245,9 +251,9 @@
// verify references
// get the key store corresponding (if it exists):
- fKeyValueStore = valueStoreCache->getGlobalValueStoreFor(((IC_KeyRef*)
fIdentityConstraint)->getKey());
+ ValueStore* keyValueStore =
valueStoreCache->getGlobalValueStoreFor(((IC_KeyRef*)
fIdentityConstraint)->getKey());
- if (!fKeyValueStore) {
+ if (!keyValueStore) {
if (fDoReportError) {
fScanner->getValidator()->emitError(XMLValid::IC_KeyRefOutOfScope,
@@ -263,7 +269,7 @@
FieldValueMap* valueMap = fValueTuples->elementAt(i);
- if (!fKeyValueStore->contains(valueMap) && fDoReportError) {
+ if (!keyValueStore->contains(valueMap) && fDoReportError) {
fScanner->getValidator()->emitError(XMLValid::IC_KeyNotFound,
fIdentityConstraint->getElementName());
Modified: xerces/c/trunk/src/xercesc/validators/schema/identity/ValueStore.hpp
URL:
http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/validators/schema/identity/ValueStore.hpp?rev=708224&r1=708223&r2=708224&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/validators/schema/identity/ValueStore.hpp
(original)
+++ xerces/c/trunk/src/xercesc/validators/schema/identity/ValueStore.hpp Mon
Oct 27 09:02:26 2008
@@ -72,6 +72,7 @@
DatatypeValidator* const dv,
const XMLCh* const value);
bool contains(const FieldValueMap* const other);
+ void clear();
// -----------------------------------------------------------------------
// Document handling methods
@@ -114,7 +115,6 @@
IdentityConstraint* fIdentityConstraint;
FieldValueMap fValues;
RefVectorOf<FieldValueMap>* fValueTuples;
- ValueStore* fKeyValueStore;
XMLScanner* fScanner; // for error reporting - REVISIT
MemoryManager* fMemoryManager;
};
Modified:
xerces/c/trunk/src/xercesc/validators/schema/identity/ValueStoreCache.cpp
URL:
http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/validators/schema/identity/ValueStoreCache.cpp?rev=708224&r1=708223&r2=708224&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/validators/schema/identity/ValueStoreCache.cpp
(original)
+++ xerces/c/trunk/src/xercesc/validators/schema/identity/ValueStoreCache.cpp
Mon Oct 27 09:02:26 2008
@@ -124,7 +124,7 @@
void ValueStoreCache::init() {
- fValueStores = new (fMemoryManager) RefVectorOf<ValueStore>(8, true,
fMemoryManager);
+ fValueStores = new (fMemoryManager) RefVectorOf<ValueStore>(8, false,
fMemoryManager);
fGlobalICMap = new (fMemoryManager) RefHashTableOf<ValueStore, PtrHasher>
(
13
@@ -134,7 +134,7 @@
fIC2ValueStoreMap = new (fMemoryManager) RefHash2KeysTableOf<ValueStore,
PtrHasher>
(
13
- , false
+ , true
, fMemoryManager
);
fGlobalMapStack = new (fMemoryManager)
RefStackOf<RefHashTableOf<ValueStore, PtrHasher> >(8, true, fMemoryManager);
@@ -149,9 +149,15 @@
for (XMLSize_t i=0; i<icCount; i++) {
IdentityConstraint* ic = elemDecl->getIdentityConstraintAt(i);
- ValueStore* valueStore = new (fMemoryManager) ValueStore(ic, fScanner,
fMemoryManager);
+ ValueStore* valueStore=fIC2ValueStoreMap->get(ic, initialDepth);
+ if(valueStore==0)
+ {
+ valueStore = new (fMemoryManager) ValueStore(ic, fScanner,
fMemoryManager);
+ fIC2ValueStoreMap->put(ic, initialDepth, valueStore);
+ }
+ else
+ valueStore->clear();
fValueStores->addElement(valueStore);
- fIC2ValueStoreMap->put(ic, initialDepth, valueStore);
}
}
@@ -167,10 +173,7 @@
if (currVals) {
currVals->append(newVals);
} else {
- ValueStore* valueStore = new (fMemoryManager) ValueStore(ic, fScanner,
fMemoryManager);
- fValueStores->addElement(valueStore);
- valueStore->append(newVals);
- fGlobalICMap->put(ic, valueStore);
+ fGlobalICMap->put(ic, newVals);
}
}
Modified:
xerces/c/trunk/src/xercesc/validators/schema/identity/ValueStoreCache.hpp
URL:
http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/validators/schema/identity/ValueStoreCache.hpp?rev=708224&r1=708223&r2=708224&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/validators/schema/identity/ValueStoreCache.hpp
(original)
+++ xerces/c/trunk/src/xercesc/validators/schema/identity/ValueStoreCache.hpp
Mon Oct 27 09:02:26 2008
@@ -28,7 +28,7 @@
* Sketch of algorithm:
* - When a constraint is first encountered, its values are stored in the
* (local) fIC2ValueStoreMap;
- * - Once it is validated (i.e., wen it goes out of scope), its values are
+ * - Once it is validated (i.e., when it goes out of scope), its values are
* merged into the fGlobalICMap;
* - As we encounter keyref's, we look at the global table to validate them.
* - Validation always occurs against the fGlobalIDConstraintMap (which
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]