JDK-8144174 : Potential off-heap memory leak, while FileChannel.map
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.nio
  • Affected Version: 8u66
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: linux
  • CPU: x86
  • Submitted: 2015-11-20
  • Updated: 2016-04-27
  • Resolved: 2015-11-27
Related Reports
Duplicate :  
Duplicate :  
Description
FULL PRODUCT VERSION :
1.8.0_66 and early


ADDITIONAL OS VERSION INFORMATION :
3.13.0-62-generic #102~precise1-Ubuntu SMP Wed Aug 12 14:09:54 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

A DESCRIPTION OF THE PROBLEM :
There is potential problem in map() method in implementation of sun.nio.ch.FileChannelImpl class. 
The problem is that the "new FileChannelImpl.Unmapper(...)" and later newMappedByteBuffer(...) invorkation will not wrapped in try-catch, but object creation MAY cause to throw OutOfMemoryError. If this happens, the previously mapped memory is not unmapped, and no way to release it.



STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
RandomAccessFile raf = new RandomAccessFile("/tmp/1.tmp", "rw");
FileChannel fc = raf.getChannel();
...do fill heap...
try{
MappedByteBuffer buf = fc.map(FileChannel.MapMode.READ_WRITE, start, len);
}catch(IOException ex){
//MAY off-heap memory leak
}



REPRODUCIBILITY :
This bug can be reproduced rarely.


Comments
Closing as duplicate of JDK-6558368 and JDK-4724038.
2015-11-27