Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce test.NewTempWindow() to avoid memory leak in test windows #4849

Merged
merged 8 commits into from
Jun 18, 2024

Conversation

Jacalz
Copy link
Member

@Jacalz Jacalz commented May 18, 2024

Description:

I noticed that we had a quite substantial memory leak in our test suite due to various tests forgetting to call .Close() on the test window that was created. This led to larger memory usage than what would be ideal. I fixed all the issues I could find and introduced a test.NewTempWindow() function to create a window that automatically closes at the end of the test.

Any places where we forgot to call Close() now uses the new function. Old uses that close the window have been left as is. Should we deprecate the old function to point people towards this safer new function?

Checklist:

  • Tests included.
  • Lint and formatter run with no errors.
  • Tests all pass.

Where applicable:

  • Public APIs match existing style and have Since: line.

@coveralls
Copy link

coveralls commented May 18, 2024

Coverage Status

coverage: 65.68% (-0.006%) from 65.686%
when pulling 7994aa1 on Jacalz:fix-test-window-memory-leak
into 759df6f on fyne-io:develop.

@andydotxyz
Copy link
Member

I don't think we should deprecate test.NewWindow as it is a legitimate thing to do.

Copy link
Member

@andydotxyz andydotxyz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like a great change, but a couple of questions inline from reading it through.

test/testwindow.go Outdated Show resolved Hide resolved
widget/entry_test.go Show resolved Hide resolved
@Jacalz Jacalz requested a review from andydotxyz May 23, 2024 09:06
andydotxyz
andydotxyz previously approved these changes Jun 17, 2024
Copy link
Member

@andydotxyz andydotxyz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice improvement thanks

@Jacalz
Copy link
Member Author

Jacalz commented Jun 17, 2024

Thanks. Had to fix a merge conflict. Needs a re-approval, I'm afraid

@Jacalz Jacalz requested a review from andydotxyz June 17, 2024 19:42
andydotxyz
andydotxyz previously approved these changes Jun 17, 2024
@Jacalz
Copy link
Member Author

Jacalz commented Jun 17, 2024

Of course there were merge conflicts again. Sigh 😮‍💨

@Jacalz Jacalz requested a review from andydotxyz June 17, 2024 21:48
@Jacalz Jacalz merged commit beb7392 into fyne-io:develop Jun 18, 2024
12 checks passed
@Jacalz Jacalz deleted the fix-test-window-memory-leak branch June 18, 2024 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants