diff --git a/app/src/main/java/io/nekohasekai/sfa/bg/BoxService.kt b/app/src/main/java/io/nekohasekai/sfa/bg/BoxService.kt
index f18100c..49698ff 100644
--- a/app/src/main/java/io/nekohasekai/sfa/bg/BoxService.kt
+++ b/app/src/main/java/io/nekohasekai/sfa/bg/BoxService.kt
@@ -122,6 +122,7 @@ class BoxService(
DefaultNetworkMonitor.start()
Libbox.registerLocalDNSTransport(LocalResolver)
+ Libbox.setMemoryLimit(!Settings.disableMemoryLimit)
val newService = try {
Libbox.newService(content, platformInterface)
diff --git a/app/src/main/java/io/nekohasekai/sfa/constant/SettingsKey.kt b/app/src/main/java/io/nekohasekai/sfa/constant/SettingsKey.kt
index 1622dc5..3c1c7d9 100644
--- a/app/src/main/java/io/nekohasekai/sfa/constant/SettingsKey.kt
+++ b/app/src/main/java/io/nekohasekai/sfa/constant/SettingsKey.kt
@@ -6,6 +6,7 @@ object SettingsKey {
const val SERVICE_MODE = "service_mode"
const val ANALYTICS_ALLOWED = "analytics_allowed"
const val CHECK_UPDATE_ENABLED = "check_update_enabled"
+ const val DISABLE_MEMORY_LIMIT = "disable_memory_limit"
// cache
diff --git a/app/src/main/java/io/nekohasekai/sfa/database/Settings.kt b/app/src/main/java/io/nekohasekai/sfa/database/Settings.kt
index ee012f5..2d8389d 100644
--- a/app/src/main/java/io/nekohasekai/sfa/database/Settings.kt
+++ b/app/src/main/java/io/nekohasekai/sfa/database/Settings.kt
@@ -42,6 +42,7 @@ object Settings {
var analyticsAllowed by dataStore.int(SettingsKey.ANALYTICS_ALLOWED) { ANALYSIS_UNKNOWN }
var checkUpdateEnabled by dataStore.boolean(SettingsKey.CHECK_UPDATE_ENABLED) { true }
+ var disableMemoryLimit by dataStore.boolean(SettingsKey.DISABLE_MEMORY_LIMIT)
fun serviceClass(): Class<*> {
return when (serviceMode) {
diff --git a/app/src/main/java/io/nekohasekai/sfa/ui/main/SettingsFragment.kt b/app/src/main/java/io/nekohasekai/sfa/ui/main/SettingsFragment.kt
index 0d457c6..13afb4c 100644
--- a/app/src/main/java/io/nekohasekai/sfa/ui/main/SettingsFragment.kt
+++ b/app/src/main/java/io/nekohasekai/sfa/ui/main/SettingsFragment.kt
@@ -74,6 +74,12 @@ class SettingsFragment : Fragment() {
}
}
}
+ binding.disableMemoryLimit.addTextChangedListener {
+ lifecycleScope.launch(Dispatchers.IO) {
+ val newValue = EnabledType.valueOf(it).boolValue
+ Settings.disableMemoryLimit = !newValue
+ }
+ }
binding.communityButton.setOnClickListener {
it.context.launchCustomTab("https://community.sagernet.org/")
}
@@ -97,6 +103,8 @@ class SettingsFragment : Fragment() {
binding.checkUpdateEnabled.isEnabled = appCenterEnabled
binding.checkUpdateEnabled.text = EnabledType.from(checkUpdateEnabled).name
binding.checkUpdateEnabled.setSimpleItems(R.array.enabled)
+ binding.disableMemoryLimit.text = EnabledType.from(!Settings.disableMemoryLimit).name
+ binding.disableMemoryLimit.setSimpleItems(R.array.enabled)
}
}
diff --git a/app/src/main/res/layout/fragment_settings.xml b/app/src/main/res/layout/fragment_settings.xml
index b02351e..7c0083d 100644
--- a/app/src/main/res/layout/fragment_settings.xml
+++ b/app/src/main/res/layout/fragment_settings.xml
@@ -87,6 +87,23 @@
+
+
+
+
+
+
Android client for sing-box, the universal proxy platform.
Documentation
Community
+ Memory Limit
\ No newline at end of file