You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2019/08/19 16:56:35 UTC

svn commit: r1865489 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDictionary.java

Author: tilman
Date: Mon Aug 19 16:56:35 2019
New Revision: 1865489

URL: http://svn.apache.org/viewvc?rev=1865489&view=rev
Log:
PDFBOX-3284: remove commented code and debug stuff, no longer needed

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDictionary.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDictionary.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDictionary.java?rev=1865489&r1=1865488&r2=1865489&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDictionary.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDictionary.java Mon Aug 19 16:56:35 2019
@@ -18,12 +18,10 @@ package org.apache.pdfbox.cos;
 
 import java.io.IOException;
 import java.io.InputStream;
-import java.lang.ref.WeakReference;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Calendar;
 import java.util.Collection;
-import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -56,7 +54,6 @@ public class COSDictionary extends COSBa
     /**
      * The name-value pairs of this dictionary. The pairs are kept in the order they were added to the dictionary.
      */
-//    protected Map<COSName, COSBase> items = new LinkedHashMap<COSName, COSBase>();
     protected Map<COSName, COSBase> items = new SmallMap<>();
 
     /**
@@ -65,7 +62,6 @@ public class COSDictionary extends COSBa
     public COSDictionary()
     {
         // default constructor
-        debugInstanceCount();
     }
 
     /**
@@ -76,65 +72,8 @@ public class COSDictionary extends COSBa
     public COSDictionary(COSDictionary dict)
     {
         items.putAll(dict.items);
-        
-        debugInstanceCount();
     }
 
-    private static final boolean DO_DEBUG_INSTANCE_COUNT = false;
-    private static final List<WeakReference<COSDictionary>> DICT_INSTANCES = 
-            DO_DEBUG_INSTANCE_COUNT ? new ArrayList<WeakReference<COSDictionary>>() : null;
-
-    /**
-     * Only for memory debugging purposes (especially PDFBOX-3284): holds weak
-     * references to all instances and prints after each 10,000th instance a
-     * statistic across all instances showing how many instances we have per
-     * dictionary size (item count).
-     * This is to show that there can be a large number of COSDictionary instances
-     * but each having only few items, thus using a {@link LinkedHashMap} is a
-     * waste of memory resources.
-     * 
-     * <p>This method should be removed if further testing of COSDictionary uses
-     * is not needed anymore.</p>
-     */
-    private void debugInstanceCount()
-    {
-        if (DO_DEBUG_INSTANCE_COUNT)
-        {
-            synchronized (DICT_INSTANCES)
-            {
-                DICT_INSTANCES.add(new WeakReference<>(this));
-                // print statistics at each 10,000th instance
-                if (DICT_INSTANCES.size() % 10000 == 0)
-                {
-                    int[] sizeCount = new int[100];
-                    for (WeakReference<COSDictionary> dict : DICT_INSTANCES)
-                    {
-                        COSDictionary curDict = dict.get();
-                        if (curDict != null)
-                        {
-                            int sizeIdx = curDict.size();
-                            sizeCount[sizeIdx < sizeCount.length ? sizeIdx
-                                    : sizeCount.length - 1]++;
-                        }
-                    }
-                    // find biggest
-                    int maxIdx = -1;
-                    int max = 0;
-                    for (int sizeIdx = 0; sizeIdx < sizeCount.length; ++sizeIdx)
-                    {
-                        if (max < sizeCount[sizeIdx])
-                        {
-                            maxIdx = sizeIdx;
-                            max = sizeCount[sizeIdx];
-                        }
-                    }
-                    System.out.println("COSDictionary: dictionary size occurrences (max idx: " + maxIdx + "): " + Arrays.toString(sizeCount));
-                }
-            }
-        }
-    }
-    
-    
     /**
      * @see java.util.Map#containsValue(java.lang.Object)
      *