Add low memory mode for supported utilities#47487
Conversation
|
@microsoft-github-policy-service agree |
22b007f to
2ba5686
Compare
|
For the Communication part of the checklist, it should read "I've discussed this with core contributors already. If the work hasn't been agreed, this work might be rejected". Have you discussed this with core contributors and had approval to start? I ask because this work seems to be of far larger scope than required to resolve the linked Color Picker issue. |
|
Thanks for calling this out. The original motivation here is broader idle memory usage, not only Color Picker. I used #10357 because it is the existing issue that describes the same background-process tradeoff in a concrete way. I have also opened a separate issue for the broader low memory mode scope: #47518 I agree the checklist wording should not imply explicit approval. I have updated the PR body to say that the scope was posted in the contribution thread and is awaiting maintainer confirmation. If maintainers prefer a narrower first step, I can reduce this PR to Color Picker only and leave the broader per-utility low memory behavior for separate discussion. |
|
This PR could solve #44397 |
|
"Low memory mode" does not describe an action and is not the most common phrase. I (and Copilot) recommend "Close app when inactive". |
Jay-o-Way
left a comment
There was a problem hiding this comment.
Strings are very redundant. Just saying.
|
|
||
| internal bool ExitAfterUse => exitAfterUse; | ||
|
|
||
| internal void ExitAfterUseIfNeeded() |
There was a problem hiding this comment.
I dunno, maybe it's me, but "if needed" sounds weird
| <value>Low memory mode</value> | ||
| </data> | ||
| <data name="GeneralPage_LowMemoryMode.Description" xml:space="preserve"> | ||
| <value>Supported utilities close when not in use to use less memory, but may open slower.</value> |
There was a problem hiding this comment.
To me, this is almost too verbose. Especially "supported utilities" feels weird. Everything that is supported is show.
| <value>Supported utilities close when not in use to use less memory, but may open slower.</value> | ||
| </data> | ||
| <data name="GeneralPage_LowMemoryModeAllSupported.Header" xml:space="preserve"> | ||
| <value>All supported utilities</value> |
| <value>Disable all</value> | ||
| </data> | ||
| <data name="GeneralPage_LowMemoryTextExtractor.Header" xml:space="preserve"> | ||
| <value>Text Extractor</value> |
There was a problem hiding this comment.
Larger scope: can't we just re-use one string?
| <value>Low memory mode for Text Extractor</value> | ||
| </data> | ||
| <data name="GeneralPage_LowMemoryTextExtractorDetails.Description" xml:space="preserve"> | ||
| <value>Close Text Extractor when not in use. Uses less memory but may open slower.</value> |
There was a problem hiding this comment.
Why not use one "anonymous" description for every string?
Summary of the Pull Request
Adds an optional low memory mode for supported utilities so PowerToys can reduce idle memory usage by closing helper/UI processes when they are not in use.
This currently covers:
The change keeps the current warm-process behavior as the default and adds per-utility low memory toggles plus enable-all/disable-all helpers in General settings.
Links:
PR Checklist
the broader scope is acceptable
Detailed Description of the Pull Request / Additional comments
This adds a shared
low_memory_modulessettings map and helper APIs so supported utilities can opt into idle-close behavior without adding a new schema field per module. Each supported utility defaults tofalse, preserving the existing warm-process behavior unless the user enables low memory mode.The runner refreshes the cached low-memory settings and reapplies the policy by restarting only affected enabled modules when a supported utility's low memory setting changes. Supported module interfaces use
PTSettingsHelper::is_low_memory_mode_enabled(...)to decide whether to keep the app process warm or launch with exit-after-use behavior.The Settings UI exposes the behavior in General settings as a status-like group of per-utility toggles, with enable-all/disable-all actions, and also adds each utility-specific toggle to the individual supported module pages.
Validation Steps Performed
src/runnerARM64 Release successfully.src/settings-ui/Settings.UIARM64 Release successfully.src/settings-ui/Settings.UI.UnitTestsARM64 Release successfully.Settings.UI.UnitTestsfilter forViewModelTests.General; 16 tests passed.