POI 60140 Prevent unnecessary memory usage -- no need to cache HeapByteBuffer in FileBackedDataSource, thanks to Luis Filipe Nassif for diagnosing this

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1760816 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Tim Allison 2016-09-15 00:19:52 +00:00
parent 7cfaa16489
commit 1265c3a9a7
1 changed files with 2 additions and 3 deletions

View File

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