Memory leak due to remaining strong references caused by property binding

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P4
    • 8
    • Affects Version/s: 7u21
    • Component/s: javafx
    • None

      Assume you have the following:
      label.textProperty().bind(person.nameProperty());

      Now assume the 'label' above is no longer part of the scene graph, and that it is no longer referenced from application code.

      If 'person' is still around, 'label' is not being garbage-collected, due to a strong reference from the 'name' property of 'person' on the 'text' property of 'label', causing a memory leak.

      This problem doesn't occur with bidirectional bindings, or low-level bindings, as in the below, given that those apparently use weak references:
      label.textProperty().bindBidirectional(person.nameProperty());

      label.textProperty().bind(new StringBinding() {
              
        {
          bind(person.nameProperty());
        }

        @Override
        protected String computeValue() {
          return person.nameProperty().get();
        }
      });

            Assignee:
            Martin Sládeček
            Reporter:
            Shant Bozian (Inactive)
            Votes:
            1 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: