Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-7162955

Attach api on Solaris, too many open files

    Details

    • Subcomponent:
      svc
    • Resolved In Build:
      b55
    • CPU:
      x86, sparc
    • OS:
      solaris_10
    • Verification:
      Verified

      Backports

        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

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  dlong Dean Long
                  Reporter:
                  webbuggrp Webbug Group
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  4 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Imported:
                    Indexed: