]> source.dussan.org Git - sonarqube.git/commitdiff
improve significantly memore consumption while using a disk cache 157/head
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>
Tue, 17 Mar 2015 17:59:01 +0000 (18:59 +0100)
committerTeryk Bellahsene <teryk.bellahsene@sonarsource.com>
Wed, 18 Mar 2015 07:39:43 +0000 (08:39 +0100)
it kept a strong reference to every object writter: http://stackoverflow.com/questions/7495155/java-out-of-heap-space-during-serialization/7495214#7495214

server/sonar-server/src/main/java/org/sonar/server/util/cache/DiskCache.java

index 9bc8e0b8ce8093cc9c80af6b74143dfaf31ac95b..34056e8deb2537fd8bfdb81ec6daa46a42cf4f36 100644 (file)
@@ -25,12 +25,7 @@ import org.sonar.api.utils.System2;
 import org.sonar.server.util.CloseableIterator;
 import org.sonar.server.util.ObjectInputStreamIterator;
 
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.ObjectOutputStream;
-import java.io.OutputStream;
-import java.io.Serializable;
+import java.io.*;
 
 /**
  * Serialize and deserialize objects on disk. No search capabilities, only traversal (full scan).
@@ -90,6 +85,7 @@ public class DiskCache<O extends Serializable> {
     public DiskAppender append(O object) {
       try {
         output.writeObject(object);
+        output.reset();
         return this;
       } catch (IOException e) {
         throw new IllegalStateException("Fail to write into file " + file, e);