]> source.dussan.org Git - poi.git/commitdiff
POI 60140 Prevent unnecessary memory usage -- no need to cache HeapByteBuffer in...
authorTim Allison <tallison@apache.org>
Thu, 15 Sep 2016 00:19:52 +0000 (00:19 +0000)
committerTim Allison <tallison@apache.org>
Thu, 15 Sep 2016 00:19:52 +0000 (00:19 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1760816 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/poi/poifs/nio/FileBackedDataSource.java

index 1b8660644863b2094f33790a416b819c40c59c5e..47637daa3a6c58e084242095f3d1813a95c698d6 100644 (file)
@@ -94,6 +94,8 @@ public class FileBackedDataSource extends DataSource {
       if (writable) {
           dst = channel.map(FileChannel.MapMode.READ_WRITE, position, length);
           worked = 0;
+          // remember the buffer for cleanup if necessary
+          buffersToClean.add(dst);  
       } else {
           // Read
           channel.position(position);
@@ -109,9 +111,6 @@ public class FileBackedDataSource extends DataSource {
       // Ready it for reading
       dst.position(0);
 
-      // remember the buffer for cleanup if necessary
-      buffersToClean.add(dst);
-      
       // All done
       return dst;
    }