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

memory leak in readObject() and writeObject() using idlj from jdk 1.6.0_14

    Details

    • Subcomponent:
    • Resolved In Build:
      b08
    • CPU:
      x86
    • OS:
      windows_xp
    • Verification:
      Not verified

      Backports

        Description

        Customer submitted the following testcase.

        $ more Example.idl
        interface Example
        {
        };

        and compiled it with.

        $ idlj -verbose Example.idl
        Parsing Example.idl
        done - Example.idl

        Generating Example
        done - Example

        created the following files

        $ ls
        ExampleHelper.java Example.idl ExampleOperations.java
        ExampleHolder.java Example.java _ExampleStub.java

        The customer explains the issue is with _ExampleStub.java

        $ more _ExampleStub.java

        /**
        * _ExampleStub.java .
        * Generated by the IDL-to-Java compiler (portable), version "3.2"
        * from Example.idl
        * Monday, October 19, 2009 3:13:55 PM PDT
        */

        public class _ExampleStub extends org.omg.CORBA.portable.ObjectImpl implements Example
        {

          // Type-specific CORBA::Object operations
          private static String[] __ids = {
            "IDL:Example:1.0"};

          public String[] _ids ()
          {
            return (String[])__ids.clone ();
          }

          private void readObject (java.io.ObjectInputStream s) throws java.io.IOException
          {
             String str = s.readUTF ();
             String[] args = null;
             java.util.Properties props = null;
             org.omg.CORBA.Object obj = org.omg.CORBA.ORB.init (args, props).string_to_object (str);
             org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl) obj)._get_delegate ();
             _set_delegate (delegate);
          }

          private void writeObject (java.io.ObjectOutputStream s) throws java.io.IOException
          {
             String[] args = null;
             java.util.Properties props = null;
             String str = org.omg.CORBA.ORB.init (args, props).object_to_string (this);
             s.writeUTF (str);
          }
        } // class _ExampleStub

        The readObject() generates an ORB which stays in the heap. It is not gc'd. This causes the OOM error in the customer's program. The customer says a similar problem exists with writeObject(). They explain that the problem with these methods is that they cause an ORB to be created. In some cases they created a threadpool and even had threads running. In customer's case these threads prevented GC of his classLoader. He strongly feels serialization should not be creating ORBs. If it is required that an ORB be created, they should be completely destroyed and ensure that all threads have exited.

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  skoppar Sunita Koppar (Inactive)
                  Reporter:
                  tstatt Terry Statt (Inactive)
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  0 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Imported:
                    Indexed: