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) {
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;
}