United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-7162955 : Attach api on Solaris, too many open files

Details
Type:
Bug
Submit Date:
2012-04-19
Status:
Closed
Updated Date:
2013-09-04
Project Name:
JDK
Resolved Date:
2012-05-04
Component:
hotspot
OS:
solaris_10
Sub-Component:
svc
CPU:
x86,sparc
Priority:
P4
Resolution:
Fixed
Affected Versions:
6u26,6u31
Fixed Versions:
hs24 (b55)

Related Reports
Backport:
Backport:
Backport:
Backport:
Backport:
Backport:
Backport:
Backport:
Backport:
Backport:

Sub Tasks

Description
FULL PRODUCT VERSION :
Java(TM) SE Runtime Environment (build 1.6.0_26-b03)

ADDITIONAL OS VERSION INFORMATION :
SunOS qs-sol10-64-a 5.10 Generic_139556-08 i86pc i386 i86pc

A DESCRIPTION OF THE PROBLEM :
My Java application connects to other JVMs using attach api to be able to connect with JMX after.

Works well on windows and linux. Almost on Solaris. The problem on solaris is the number of open file for each JVM receiving attach connection and the one creating it always increase. After few days it was 10k open files for each JVM.



STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
 - Run sample with one arg to have a running JVM.
 - Run sample with no arg to attach on the other one.
 - Check open files for the first JVM process while attach/detach JVMs.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Number of open files should remain stable.
ACTUAL -
Number of open files always increase.

ERROR MESSAGES/STACK TRACES THAT OCCUR :
None.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
package attach;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.List;
import java.util.Properties;

import com.sun.tools.attach.AttachNotSupportedException;
import com.sun.tools.attach.VirtualMachine;
import com.sun.tools.attach.VirtualMachineDescriptor;

public class Main {

    public static void main(String[] args) {
        if (args.length == 1) {
            int i = 0;
            while (true) {
                i++;
                try {
                    Thread.sleep(10000L);
                } catch (InterruptedException e) {
                }
            }
        } else {
            getVmInfos();
        }
    }

    public static void getVmInfos() {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String tmp;
        boolean again = true;

        while (again) {
            List<VirtualMachineDescriptor> vms = VirtualMachine.list();
            for (VirtualMachineDescriptor vmd : vms) {

                System.out.println("Name: " + vmd.displayName() + " , id: " + vmd.id() + ", Tostring: " + vmd.toString());

                try {
                    VirtualMachine vm = VirtualMachine.attach(vmd);
                    Properties agentProps = vm.getAgentProperties();

                    System.out.println("Detach? ");
                    tmp = br.readLine();
                    if (tmp.startsWith("y")) {
                        vm.detach();
                    }

                } catch (AttachNotSupportedException x) {
                    x.printStackTrace();
                } catch (NumberFormatException e) {
                    e.printStackTrace();
                } catch (Throwable e) {
                    e.printStackTrace();
                }
            }
            
            try {
                System.out.println("Again? ");
                tmp = br.readLine();
                again = tmp.startsWith("y");
            } catch (IOException e) {
                e.printStackTrace();
            }
            
        }
    }

}

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Use linux :P

                                    

Comments
EVALUATION

Need to release server-side socket after client receives it.
                                     
2012-04-26
EVALUATION

http://hg.openjdk.java.net/hsx/hotspot-emb/hotspot/rev/973046802b6f
                                     
2012-04-27
EVALUATION

http://hg.openjdk.java.net/hsx/hotspot-rt/hotspot/rev/973046802b6f
                                     
2012-05-12
EVALUATION

http://hg.openjdk.java.net/lambda/lambda/hotspot/rev/973046802b6f
                                     
2012-06-29
URL:   http://hg.openjdk.java.net/hsx/hsx24/hotspot/rev/ae08248e0ed0
User:  amurillo
Date:  2013-07-26 22:45:30 +0000

                                     
2013-07-26



Hardware and Software, Engineered to Work Together