Skip to content
This repository has been archived by the owner on Jun 24, 2021. It is now read-only.

JDK-8228358: Array Size is getting bigger in VirtualFlow.ArrayLinkedList #530

Open
leehimchan opened this issue Jul 17, 2019 · 7 comments
Open

Comments

@leehimchan
Copy link

I'd like to open bug, about ArrayLinkedList's array size.
When moving focus in Listview automatically, click scroll and moving scroll.
Then array size is getting bigger and make OOM

public void initialize(URL location, ResourceBundle resources) {

    try {
        final List<TimeZone> timeZones = Stream.of(TimeZone.getAvailableIDs())
            .map(TimeZone::getTimeZone)
            .collect(toList());
        fxList.getItems().addAll(timeZones.stream().map(x -> x.getID() + " - " + x.getDisplayName()).collect(toList()));

        final Field getVirtualFlow = Parent.class.getDeclaredField("top");
        getVirtualFlow.setAccessible(true);
        final Field getPile = VirtualFlow.class.getDeclaredField("pile");
        getPile.setAccessible(true);
        final Field getArray = VirtualFlow.ArrayLinkedList.class.getDeclaredField("array");
        getArray.setAccessible(true);


        final Random random = new Random();

        final Thread thread = new Thread(() -> {
            try {
                VirtualFlow virtualFlow;
                do {
                    sleep(100);
                    virtualFlow = (VirtualFlow) getVirtualFlow.get(fxList);
                } while (virtualFlow == null);
                final VirtualFlow.ArrayLinkedList pile = (VirtualFlow.ArrayLinkedList) getPile.get(virtualFlow);
                final ArrayList<?> array = (ArrayList<?>) getArray.get(pile);

                while (true) {
                    sleep(50);
                    final int index;
                    index = random.nextInt(fxList.getItems().size());
                    Platform.runLater(() -> {
                        fxList.scrollTo(index);
                        fxList.getSelectionModel().select(index);
                        fxItems.setText("items : " + fxList.getItems().size());
                        fxPile.setText("piles : " + pile.size());
                        fxArray.setText("array : " + array.size());
                    });
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        });
        thread.setDaemon(true);
        thread.start();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}

test-javafx-virtualflow-pile-leak.zip

@kevinrushforth
Copy link
Collaborator

If you have a test case that reproduces this, please file a bug at bugreport.java.com/? We will need a small, self-contained test program, not an executable jar file with a number of dependencies. You can refer to this GitHub issue in your submission.

@leehimchan
Copy link
Author

test-javafx-virtualflow-pile-leak.zip
I attache source file, please check it.

@kevinrushforth
Copy link
Collaborator

@kevinrushforth kevinrushforth changed the title Array Size is getting bigger in VirtualFlow.ArrayLinkedList JDK-8228358: Array Size is getting bigger in VirtualFlow.ArrayLinkedList Jul 18, 2019
@kevinrushforth
Copy link
Collaborator

kevinrushforth commented Jul 18, 2019

@leehimchan Can you please provide a test program that does not use any internal API (meaning no reference to any com.sun.javafx classes and no calls to setAccessible). The attached program doesn't compile on the latest version of openjfx, since VirtualFlow is public API as of FX 9.

@kevinrushforth
Copy link
Collaborator

After commenting out the calls to VirtualFlow (the test program was using internal API from FX 8), which were being used to instrument the code to see the size of pile.array, I was able to get the test program running.

I ran it for several minutes and see no evidence of a leak. What I do see when I instrument the JavaFX runtime itself is that the array grows to fit the maximum needed at any one time, but it doesn't keep growing. In my case, I saw the single array grow from 50 to 75 over time and then stay there. Maybe on a faster system, with more updates prior to clearing it, I could see it grow farther. How high are you seeing it get?

@leehimchan
Copy link
Author

20190722_095338.zip
I attached video file that I reproduced the situation.
When moving focus, click scroll bar and move scroll.

@kevinrushforth
Copy link
Collaborator

I'll give that a try, thanks.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants