Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 6632696
Votes 0
Synopsis Writing to closed output files (writeBytes) leaks native memory (unix)
Category java:classes_io
Reported Against
Release Fixed 7(b25)
State 10-Fix Delivered, bug
Priority: 2-High
Related Bugs
Submit Date 21-NOV-2007
Description
The function
./src/share/native/java/io/io_util.c:writeBytes
leaks memory if the stream is closed and more than 8kb of data is to be written

Self-explanatory shell transcript follows:

 $ cat ioLeak.java; echo ---; (ulimit -v 200000; jver 7 jr -Xmx6m ioLeak)
import java.io.*;

public class ioLeak {
    public static void main(String[] args) throws Throwable {
        FileOutputStream s = new FileOutputStream(new File("foo"));
        s.close();
        for (int n = 0; n < 10000 ; n++) {
            try { s.write(new byte[100000]); }
            catch (IOException e) { /* ignore */ }
            catch (OutOfMemoryError e) {
                System.out.println(n);
                return;
            }
        }
    }
}
---
==> javac ioLeak.java
==> java -Xmx6m ioLeak
730
Posted Date : 2007-11-21 04:48:41.0
Work Around
N/A
Evaluation
Here's the obvious fix:

--- /u/martin/ws/dolphin/src/share/native/java/io/io_util.c	2007-05-13 03:08:26.882713000 -0700
+++ /u/martin/ws/process/src/share/native/java/io/io_util.c	2007-11-20 20:25:09.024661000 -0800
@@ -173,7 +173,7 @@
 	    fd = GET_FD(this, fid);
 	    if (fd == -1) {
         	JNU_ThrowIOException (env, "Stream Closed");
-            	return;
+            	break;
     	    }
 	    n = IO_Write(fd, buf+off, len);
 	    if (n == JVM_IO_ERR) {
Posted Date : 2007-11-21 04:48:41.0
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang