Skip to content

Fix memory reset bug#1996

Merged
petebankhead merged 4 commits intoqupath:mainfrom
petebankhead:memory-reset
Sep 23, 2025
Merged

Fix memory reset bug#1996
petebankhead merged 4 commits intoqupath:mainfrom
petebankhead:memory-reset

Conversation

@petebankhead
Copy link
Member

@petebankhead petebankhead commented Sep 23, 2025

Fixes #1946 (I hope).

This also changes the max memory preference from requiring the memory to be defined in GB to instead using a percentage of available memory. I think this is easier to reason about, and also means we can constrain it to be between 10% and 90%.

This is a bit convoluted, because we need to try to read the current max memory from the config - since we can't rely upon the preference being correct. For example, having duplicate QuPath installations where they have the same (major/minor) version would result in them using the same preference key, but having different config files. The config files are what matters for setting the memory during launch. Another reason the preference might not match the reality is if the config file was edited externally.

There are still ways to thwart this, e.g. using a config file that specifies the max memory multiple times or in different ways (e.g. using -Xmx) but I think that's tolerable.

@petebankhead petebankhead added this to the v0.7.0 milestone Sep 23, 2025
@petebankhead
Copy link
Member Author

@Rylern @alanocallaghan I've requested reviews mostly so you know about the changes - and especially the move to specifying a percentage rather than absolute value.

It's a thoroughly miserable thing to write/check, since it requires making builds and constantly restarting QuPath. I'd like to just merge this - since it seems to be working well enough for me on both Windows and Mac.

But it's certainly inelegant, anyway else is welcome to improve it :)

@petebankhead
Copy link
Member Author

If you want it test it locally, currently you'll need to run

./gradlew wrapper --gradle-version 8.14.3

first until the runtime plugin is updated for gradle 9 compatibility.

@petebankhead petebankhead merged commit 8c11594 into qupath:main Sep 23, 2025
3 checks passed
@petebankhead petebankhead deleted the memory-reset branch September 23, 2025 18:47
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.

Resetting preferences on Windows set max memory to 512 MB

1 participant