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

JDK1.1.6: get OutOfMemoryError due to finalize() methods not being called.

    XMLWordPrintable

Details

    • sparc
    • solaris_2.6

    Description

      get OutOfMemoryError due to finalize() methods not being called.

      There exists the following 2 memory bug problems in JDK1.1.6.

      BUG #1
      ------
      When calling System.runFinalization() or Runtime.runFinalization() it
      does not run the finalize() methods of objects that are no longer
      referenced. This is a bug. When you call these methods it should
      call the finalize() methods of objects that are no longer referenced.
      It waits until I get a "java.lang.OutOfMemoryError" before it then
      decides to call the finalize() methods of objects. See BUG #2.

      BUG #2
      ------
      Because of BUG #1 I get a "java.lang.OutOfMemoryError" when I shouldn't.
      What happens is I allocate 4 objects > 2M each. Then I remove the references
      to these objects and call System.runFinalization() and System.gc().
      However these objects are not garbabge collected and there finalize()
      methods are not called. Now when I try to allocate another 4 objects of > 2M
      each I get a "java.lang.OutOfMemoryError" when I shouldn't and the finalize()
      methods of the previous objects get called and these objects get garbage
      collected. The next allocation of 4 objects > 2M each succeeds because
      of these objects now garbage collected.

      The problem is I never should have goten the "java.lang.OutOfMemoryError"
      to begin with. I would not of got it if the objects finalize() methods
      were called when I invoked System.runFinalization() after I removed all
      references to these objects.

      This seems like a bug in the garbage collection algorithm.

      The following program reproduces this problem on JDK1.1.6.

      The program is part of the attachment.

      Here is how to compile and run the program.

      % javac MemBug.java
      % java MemBug

      Attachments

        Activity

          People

            apalanissunw Anand Palaniswamy (Inactive)
            aefreche Alan Frechette (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: