<!DOCTYPE html><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body>
    I think you might be right. I see that you created a Draft PR. Can
    you also file a bug?<br>
    <br>
    -- Kevin<br>
    <br>
    <br>
    <div class="moz-cite-prefix">On 9/27/2024 2:07 PM, Thiago Milczarek
      Sayão wrote:<br>
    </div>
    <blockquote type="cite" cite="mid:CAAP_wumVMtAd_oy2wcX+7zs7Zi9US2VwbvWkdgMJ710G2JmiAQ@mail.gmail.com">
      
      <div dir="ltr">Hi,<br>
        <div><br>
        </div>
        <div>Pardon me If I'm bothering with nonsense, but I really
          think there's a leak, mainly because <span style="font-family:"JetBrains Mono",monospace;font-size:9.8pt;background-color:rgb(30,31,34);color:rgb(188,190,196)">DrawableInfo</span> is
          never freed (I did not find any code that frees it).</div>
        <div><br>
        </div>
        <div>Using valgrind, I see *many* entries like this:</div>
        <div><br>
        </div>
        <div>==28403== 1,464 bytes in 61 blocks are still reachable in
          loss record 15,444 of 16,301<br>
          ==28403==    at 0x4846828: malloc (in
          /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)<br>
          ==28403==    by 0x2BF83E5C:
          Java_com_sun_prism_es2_X11GLDrawable_nCreateDrawable (in
          /home/tsayao/IdeaProjects/jfx/build/sdk/lib/libprism_es2.so)<br>
          ==28403==    by 0x15E9FB3B: ???<br>
          ==28403==    by 0x15E9B2D5: ???<br>
          ==28403==    by 0x15E9B1DF: ???<br>
          ==28403==    by 0x15E9B379: ???<br>
          ==28403==    by 0xED02F83: ???<br>
          ==28403==    by 0xED267B3: ???<br>
          ==28403==    by 0x15E9B1DF: ???<br>
          ==28403==    by 0x15E9B6E5: ???<br>
          ==28403==    by 0x15E9B6E5: ???<br>
          ==28403==    by 0x15E9B1DF: ???<br>
        </div>
        <div><br>
        </div>
        <div><br>
        </div>
        <div><br>
        </div>
        <div>Valgrind command:</div>
        <div>valgrind --leak-check=full --track-origins=yes
          --show-leak-kinds=all --suppressions=java.supp
           --log-file=valgrind.log java
          @/home/tsayao/IdeaProjects/jfx/build/run.args TestScenes.java</div>
        <div><br>
        </div>
        <div>Suppression file (java.supp):</div>
        <div>{<br>
             # Suppress Java's native code memory allocations<br>
             Memcheck:Leak<br>
             obj:/usr/lib/jvm/jdk-22-oracle-x64/lib/server/libjvm.so<br>
             fun:malloc<br>
             fun:calloc<br>
             fun:realloc<br>
             fun:free<br>
          }<br>
        </div>
        <div><br>
        </div>
        <div>TestScenes.java:</div>
        <div>public class TestScenes extends Application {<br>
          <br>
              @Override<br>
              public void start(Stage stage) {<br>
                  // Create a timeline animation to switch between
          scenes<br>
                  Timeline timeline = new Timeline(<br>
                          new KeyFrame(Duration.millis(100), e ->
          stage.setScene(createScene("Scene 1", Color.RED))),<br>
                          new KeyFrame(Duration.millis(200), e ->
          stage.setScene(createScene("Scene 2", Color.BLUE))),<br>
                          new KeyFrame(Duration.millis(300), e ->
          stage.setScene(createScene("Scene 3", Color.GREEN)))<br>
                  );<br>
          <br>
                  timeline.setCycleCount(Animation.INDEFINITE);<br>
                  timeline.play();<br>
          <br>
                  stage.show();<br>
              }<br>
          <br>
              private Scene createScene(String text, Color color) {<br>
                  return new Scene(new StackPane(), 400, 300, color);<br>
              }<br>
          <br>
              public static void main(String[] args) {<br>
                  launch(TestScenes.class, args);<br>
              }<br>
          }<br>
        </div>
        <div><br>
        </div>
        <div><br>
        </div>
        <div> <br>
        </div>
      </div>
      <br>
      <div class="gmail_quote">
        <div dir="ltr" class="gmail_attr">Em qui., 26 de set. de 2024 às
          08:14, Thiago Milczarek Sayão <<a href="mailto:thiago.sayao@gmail.com" moz-do-not-send="true" class="moz-txt-link-freetext">thiago.sayao@gmail.com</a>>
          escreveu:<br>
        </div>
        <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
          <div dir="ltr">Hi,
            <div><br>
            </div>
            <div>I'm investigating the code, and for someone not
              familiar with it, it's very complex.</div>
            <div><br>
            </div>
            <div>On com.sun.javafx.tk.quantum.WindowStage it will do
              this when changing scene:</div>
            <div>
              <div style="background-color:rgb(30,31,34);color:rgb(188,190,196)">
                <pre style="font-family:"JetBrains Mono",monospace;font-size:9.8pt"><span style="color:rgb(207,142,109)">if </span>(oldScene != <span style="color:rgb(207,142,109)">null</span>) {
    ViewPainter painter = ((ViewScene)oldScene).getPainter();
    QuantumRenderer.<span style="font-style:italic">getInstance</span>().disposePresentable(painter.<span style="color:rgb(199,125,187)">presentable</span>);   <span style="color:rgb(122,126,133)">// latched on RT
</span>}
</pre>
              </div>
            </div>
            <div>But not when closing the Sage (possible problem #1).</div>
            <div><br>
            </div>
            <div>When changing scenes, ES2SwapChain dispose will be
              called:</div>
            <div><br>
            </div>
            <div>
              <div style="background-color:rgb(30,31,34);color:rgb(188,190,196)">
                <pre style="font-family:"JetBrains Mono",monospace;font-size:9.8pt"><span style="color:rgb(207,142,109)">public void </span><span style="color:rgb(86,168,245)">dispose</span>() {
    <span style="color:rgb(207,142,109)">if </span>(<span style="color:rgb(199,125,187)">stableBackbuffer </span>!= <span style="color:rgb(207,142,109)">null</span>) {
        <span style="color:rgb(199,125,187)">stableBackbuffer</span>.dispose();
        <span style="color:rgb(199,125,187)">stableBackbuffer </span>= <span style="color:rgb(207,142,109)">null</span>;
    }
}
</pre>
              </div>
            </div>
            <div><br>
            </div>
            <div>But it does not dispose the  drawable that should clear
              the native struc <span style="font-family:"JetBrains Mono",monospace;font-size:9.8pt;background-color:rgb(30,31,34);color:rgb(188,190,196)">DrawableInfo</span> created,
              I think (possible problem #2).</div>
            <div><br>
            </div>
            <div>Does it make sense?</div>
            <div><br>
            </div>
            <div>-- Thiago.</div>
            <div><br>
            </div>
            <div><br>
            </div>
          </div>
          <br>
          <div class="gmail_quote">
            <div dir="ltr" class="gmail_attr">Em ter., 24 de set. de
              2024 às 14:10, Thiago Milczarek Sayão <<a href="mailto:thiago.sayao@gmail.com" target="_blank" moz-do-not-send="true" class="moz-txt-link-freetext">thiago.sayao@gmail.com</a>>
              escreveu:<br>
            </div>
            <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
              <div dir="ltr">I might be mistaken, but it seems <span style="font-family:"JetBrains Mono",monospace;font-size:9.8pt;background-color:rgb(30,31,34);color:rgb(188,190,196)">deleteDrawableInfo</span> is
                never called.
                <div><br>
                </div>
                <div>I think it should be called when the platform View
                  is replaced or when the window is closed.</div>
                <div><br>
                </div>
                <div>
                  <div>Github search for <span style="background-color:rgb(30,31,34);color:rgb(188,190,196);font-family:"JetBrains Mono",monospace;font-size:13.0667px">deleteDrawableInfo</span></div>
                  <div><a href="https://github.com/search?q=repo%3Aopenjdk%2Fjfx%20deleteDrawableInfo&type=code" target="_blank" moz-do-not-send="true">https://github.com/search?q=repo%3Aopenjdk%2Fjfx%20deleteDrawableInfo&type=code</a><br>
                  </div>
                </div>
              </div>
              <br>
              <div class="gmail_quote">
                <div dir="ltr" class="gmail_attr">Em ter., 24 de set. de
                  2024 às 09:07, Thiago Milczarek Sayão <<a href="mailto:thiago.sayao@gmail.com" target="_blank" moz-do-not-send="true" class="moz-txt-link-freetext">thiago.sayao@gmail.com</a>>
                  escreveu:<br>
                </div>
                <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
                  <div dir="ltr">Hi,<br>
                    <div><br>
                    </div>
                    <div>While doing some work on replacing GLX with EGL
                      I discovered a possible leak.</div>
                    <div><br>
                    </div>
                    <div>Running this test:</div>
                    <div>gradle -PFULL_TEST=true -PUSE_ROBOT=true
                       :systemTests:test --tests SetSceneScalingTest<br>
                    </div>
                    <div><br>
                    </div>
                    <div>will result in X11GLDrawable ->
                      nCreateDrawable to be called multiple times on the
                      same test, while GLDrawable ->
                      deleteDrawableInfo is never called, generating a
                      leak (I think).</div>
                    <div><br>
                    </div>
                    <div>I can probably fix this, but I still have
                      little knowledge on the es2 part, so any help
                      would be appreciated.</div>
                    <div><br>
                    </div>
                    <div>-- Thiago.</div>
                    <div><br>
                    </div>
                  </div>
                </blockquote>
              </div>
            </blockquote>
          </div>
        </blockquote>
      </div>
    </blockquote>
    <br>
  </body>
</html>