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

Decide whether this can be GCed

    XMLWordPrintable

Details

    • Enhancement
    • Status: Closed
    • P3
    • Resolution: Duplicate
    • 9
    • 9
    • hotspot
    • None
    • gc
    • generic
    • generic

    Description

      It turned out during discussion about lightweight finalization (see JDK-8051843) that people often blame finalization for misbehavior which is not necessarily related to finalization, rather to VM behavior. In my opinion (as expressed at http://mail.openjdk.java.net/pipermail/core-libs-dev/2014-August/028215.html ) it boils down to question whether following method can finish or not:

          private void gcThis() {
              Reference<?> ref = new WeakReference<>(this);
              while (ref.get() != null) {
                  System.gc();
              }
              System.err.println("ref is gone: " + ref);
          }

      my personal suggestion is that it should never finish, however I am not the right person to decide that. Rather I just report this issue to track the decision made by others. I just want to express my developer wish: sometimes I want "this" to not be GCed while its instance method is running and it would be nice to have cross VM way to enforce that.

      Attachments

        Issue Links

          Activity

            People

              dl Doug Lea
              jtulach Jaroslav Tulach (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: