Author: toad
Date: 2006-01-28 01:20:12 +0000 (Sat, 28 Jan 2006)
New Revision: 7963

Modified:
   trunk/freenet/src/freenet/client/StandardOnionFECCodec.java
   trunk/freenet/src/freenet/node/Version.java
Log:
414:
Mostly tracking memory leaks in FEC encoding.

Modified: trunk/freenet/src/freenet/client/StandardOnionFECCodec.java
===================================================================
--- trunk/freenet/src/freenet/client/StandardOnionFECCodec.java 2006-01-28 
01:07:36 UTC (rev 7962)
+++ trunk/freenet/src/freenet/client/StandardOnionFECCodec.java 2006-01-28 
01:20:12 UTC (rev 7963)
@@ -344,10 +344,10 @@
        private void realEncode(Bucket[] dataBlockStatus,
                        Bucket[] checkBlockStatus, int blockLength, 
BucketFactory bf)
                        throws IOException {
-//             Runtime.getRuntime().gc();
-//             Runtime.getRuntime().runFinalization();
-//             Runtime.getRuntime().gc();
-//             Runtime.getRuntime().runFinalization();
+               Runtime.getRuntime().gc();
+               Runtime.getRuntime().runFinalization();
+               Runtime.getRuntime().gc();
+               Runtime.getRuntime().runFinalization();
                long memUsedAtStart = Runtime.getRuntime().totalMemory() - 
Runtime.getRuntime().freeMemory();
                Logger.minor(this, "Memory in use at start: "+memUsedAtStart+" 
max="+Runtime.getRuntime().maxMemory());
                Logger.minor(this, "Doing encode: " + dataBlockStatus.length
@@ -404,11 +404,20 @@
                                }
                        }

+                       Runtime.getRuntime().gc();
+                       Runtime.getRuntime().runFinalization();
+                       Runtime.getRuntime().gc();
+                       Runtime.getRuntime().runFinalization();
+                       long memUsedBeforeEncodes = 
Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
+                       Logger.minor(this, "Memory in use before encodes: 
"+memUsedBeforeEncodes);
+                       
                        if (numberToEncode > 0) {
                                System.err.println("************* Encoding " + 
dataBlockStatus.length
                                                + " -> " + numberToEncode + " 
*************");
                                // Do the (striped) encode
                                for (int offset = 0; offset < blockLength; 
offset += STRIPE_SIZE) {
+                                       long memUsedBeforeRead = 
Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
+                                       Logger.minor(this, "Memory in use 
before read: "+memUsedBeforeRead);
                                        // Read the data in first
                                        for (int i = 0; i < k; i++) {
                                                
readers[i].readFully(realBuffer, i * STRIPE_SIZE,
@@ -417,17 +426,17 @@
                                        // Do the encode
                                        // Not shuffled
                                        long startTime = 
System.currentTimeMillis();
-//                                     Runtime.getRuntime().gc();
-//                                     Runtime.getRuntime().runFinalization();
-//                                     Runtime.getRuntime().gc();
-//                                     Runtime.getRuntime().runFinalization();
+                                       Runtime.getRuntime().gc();
+                                       Runtime.getRuntime().runFinalization();
+                                       Runtime.getRuntime().gc();
+                                       Runtime.getRuntime().runFinalization();
                                        long memUsedBeforeStripe = 
Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
                                        Logger.minor(this, "Memory in use 
before stripe: "+memUsedBeforeStripe);
                                        encoder.encode(dataPackets, 
checkPackets, toEncode);
-//                                     Runtime.getRuntime().gc();
-//                                     Runtime.getRuntime().runFinalization();
-//                                     Runtime.getRuntime().gc();
-//                                     Runtime.getRuntime().runFinalization();
+                                       Runtime.getRuntime().gc();
+                                       Runtime.getRuntime().runFinalization();
+                                       Runtime.getRuntime().gc();
+                                       Runtime.getRuntime().runFinalization();
                                        long memUsedAfterStripe = 
Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
                                        Logger.minor(this, "Memory in use after 
stripe: "+memUsedAfterStripe);
                                        long endTime = 
System.currentTimeMillis();

Modified: trunk/freenet/src/freenet/node/Version.java
===================================================================
--- trunk/freenet/src/freenet/node/Version.java 2006-01-28 01:07:36 UTC (rev 
7962)
+++ trunk/freenet/src/freenet/node/Version.java 2006-01-28 01:20:12 UTC (rev 
7963)
@@ -20,7 +20,7 @@
        public static final String protocolVersion = "1.0";

        /** The build number of the current revision */
-       private static final int buildNumber = 413;
+       private static final int buildNumber = 414;

        /** Oldest build of Fred we will talk to */
        private static final int lastGoodBuild = 403;


Reply via email to