You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commons-dev@ws.apache.org by sc...@apache.org on 2008/05/05 20:01:42 UTC

svn commit: r653541 - /webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/factory/OMLinkedListImplFactory.java

Author: scheu
Date: Mon May  5 11:01:42 2008
New Revision: 653541

URL: http://svn.apache.org/viewvc?rev=653541&view=rev
Log:
The OMNamespace objects are no longer pooled.  The OMNamespace objects are small (two strings), and the overhead of building the key and pooling the objects degrades performance.   Plus the pool is never resized; thus it leads to long running bloat.
Contributor: David Strite

Modified:
    webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/factory/OMLinkedListImplFactory.java

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/factory/OMLinkedListImplFactory.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/factory/OMLinkedListImplFactory.java?rev=653541&r1=653540&r2=653541&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/factory/OMLinkedListImplFactory.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/factory/OMLinkedListImplFactory.java Mon May  5 11:01:42 2008
@@ -51,12 +51,18 @@
 public class OMLinkedListImplFactory implements OMFactory {
 
     private static final String uriAndPrefixSeparator = ";";
+    
+    
+    // Pooling of OMNamespace objects is disabled.  See the comment in OMNamespace.
+    private static boolean POOL_OMNAMESPACES = false;
+    
     /**
      * This is a map of namespaces with the namespace URI as the key and Namespace object itself as
      * the value.
      * OMFactories are shared across threads.  The Hashtable is necessary to prevent concurrent modification exceptions.
      */
     protected Map namespaceTable = new Hashtable(5);
+    
 
     /**
      * Method createOMElement.
@@ -154,16 +160,27 @@
      * @return Returns OMNamespace.
      */
     public OMNamespace createOMNamespace(String uri, String prefix) {
-        String key = uri;
-        if (prefix != null && prefix.length() > 0) {
-            key = key + uriAndPrefixSeparator + prefix;
-        }
-        OMNamespace existingNamespaceObject = (OMNamespace) namespaceTable.get(key);
-        if (existingNamespaceObject == null) {
-            existingNamespaceObject = new OMNamespaceImpl(uri, prefix);
-            namespaceTable.put(key, existingNamespaceObject);
+        // An OMNamespaceImpl consists of only two String objects;
+        // The overhead to create "yet another" key string and pool these
+        // small objects is unnecessary.  In addition,
+        // the objects are never freed from the pool, which means that the
+        // the table will grow very large over time.  For this reason, the
+        // pooling of OMNamespaces is disabbled.
+        
+        if (POOL_OMNAMESPACES) {
+            String key = uri;
+            if (prefix != null && prefix.length() > 0) {
+                key = key + uriAndPrefixSeparator + prefix;
+            }
+            OMNamespace existingNamespaceObject = (OMNamespace) namespaceTable.get(key);
+            if (existingNamespaceObject == null) {
+                existingNamespaceObject = new OMNamespaceImpl(uri, prefix);
+                namespaceTable.put(key, existingNamespaceObject);
+            }
+            return existingNamespaceObject;
+        } else {
+            return new OMNamespaceImpl(uri, prefix);
         }
-        return existingNamespaceObject;
     }
 
     /**