Decide whether this can be GCed

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Duplicate
    • Priority: P3
    • 9
    • Affects Version/s: 9
    • Component/s: hotspot
    • None
    • gc
    • generic
    • generic

      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.

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

              Created:
              Updated:
              Resolved: