United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-8144174 : Potential off-heap memory leak, while FileChannel.map

Details
Type:
Bug
Submit Date:
2015-11-20
Status:
Closed
Updated Date:
2016-04-27
Project Name:
JDK
Resolved Date:
2015-11-27
Component:
core-libs
OS:
linux
Sub-Component:
java.nio
CPU:
x86
Priority:
P4
Resolution:
Duplicate
Affected Versions:
8u66
Fixed Versions:

Related Reports
Duplicate:
Duplicate:

Sub Tasks

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



Hardware and Software, Engineered to Work Together