Author: tallison
Date: Thu Sep 15 00:19:52 2016
New Revision: 1760816

URL: http://svn.apache.org/viewvc?rev=1760816&view=rev
Log:
POI 60140 Prevent unnecessary memory usage -- no need to cache HeapByteBuffer 
in FileBackedDataSource, thanks to Luis Filipe Nassif for diagnosing this

Modified:
    poi/trunk/src/java/org/apache/poi/poifs/nio/FileBackedDataSource.java

Modified: poi/trunk/src/java/org/apache/poi/poifs/nio/FileBackedDataSource.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/poifs/nio/FileBackedDataSource.java?rev=1760816&r1=1760815&r2=1760816&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/poifs/nio/FileBackedDataSource.java 
(original)
+++ poi/trunk/src/java/org/apache/poi/poifs/nio/FileBackedDataSource.java Thu 
Sep 15 00:19:52 2016
@@ -94,6 +94,8 @@ public class FileBackedDataSource extend
       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 extend
       // Ready it for reading
       dst.position(0);
 
-      // remember the buffer for cleanup if necessary
-      buffersToClean.add(dst);
-      
       // All done
       return dst;
    }



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to