Feature/background memory save - #807
Open
LiangNuoXuan wants to merge 7 commits into
Open
Conversation
Add a setting toggle that automatically kills the UI process 3 seconds after the app goes to background, freeing UI memory while ClashService keeps running in the :background process. - UiStore: add autoDestroyUI preference - AppSettingsDesign: add toggle below "hide from recents" - MainApplication: observe app visibility and kill UI process - ApplicationObserver: support multiple visibility listeners (was overwritten by Remote.launch, breaking our callback)
ic_baseline_hide was already used by hideAppIcon switch right above; use ic_baseline_close to avoid duplicate icons on adjacent settings.
|
https://developer.android.com/guide/components/activities/process-lifecycle?hl=zh-cn 建议学习Android应用的生命周期,尤其是缓存进程一节。 |
Replace Process.killProcess with finishing all activities and triggering GC. This avoids bypassing Android lifecycle (Activity.onDestroy, Service .onDestroy) and resolves LogcatService state leak issues while still releasing UI memory (View trees, design objects).
Core services (ClashService, TunService, RemoteService) and VPN run in :background process, unaffected by killing UI process. LogcatService only starts when user opens logs screen; static 'running' flag resets on new process launch. Killing UI process is the cleanest way to release all UI memory (Activities, Views, Design objects, Application singletons).
- Remove redundant ApplicationObserver.attach (Remote.launch already calls it); register our listener before Remote.launch so we don't miss the first visibility event. - Remove unused isAppVisible getter. Keep changes strictly limited to UI process memory management.
Author
好的,我写的是开关由用户自己决定 |
- Add protected activities whitelist to prevent killing during edits - Add pendingExternalRequest flag to protect VPN authorization flow - Add polling-based detection (wait when protected, kill when idle) - Add auto_destroy.log for persistent self-destroy tracking - Fix type inference for protectedActivities Set<Class<*> - Complete translations for 6 additional languages
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
’应用进入后台3秒后自动销毁界面以节省内存‘ 开关
