Skip to content

Commit 279e10a

Browse files
Prevent OOM-killing
Prevent OOM-kills by the kernel by setting the oom_score_adj to its minimum. We need to do this periodically, because android also changes this value on certain evens, eg assigning a lower score when the app is open and a higher score when the app is in the background.
1 parent 14c7c08 commit 279e10a

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ It contains many useability enhancements and all the major fixes needed to run `
5454
`ViPER4Android 2.7` comes with `Crashlytics bug report metrics` enabled by default. Personally I don't like to send bug reports, so I always disable it. I think Opt-in is the way to go here.
5555
This is why in this module `Crashlytics` is disabled by default and you may enable if it you wish to.
5656
* **Keep the vibes alive** \
57-
`ViPER4Android` will automatically be restarted if it gets killed. This may be of great convenience on low ram devices, where the OOM-killer is very aggressive, even towards foreground services.
57+
Measures have been put in place to ensure `ViPER4Android` doesn't get killed by the OOM-killer.
58+
Though should `ViPER4Android` stop working anyways, will automatically be restarted.
59+
This may be of great convenience on low ram devices, where the OOM-killer is very aggressive, even towards foreground services.
5860

5961
## Install
6062

magiskmodule/service.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,21 @@ waitUntilBootCompleted() {
66
done
77
}
88

9+
VIPERFXPACKAGE="com.pittvandewitt.viperfx"
10+
911
(
1012
waitUntilBootCompleted
1113
sleep 10
12-
VIPERFXPACKAGE="com.pittvandewitt.viperfx"
1314
[ -n "$(pm list packages -d | grep $VIPERFXPACKAGE)" ] && pm enable $VIPERFXPACKAGE
1415
) &
1516

1617
(
1718
waitUntilBootCompleted
1819
sleep 60
1920
while true; do
20-
ps -A -w -o ARGS=CMD | grep -v grep | grep -q com.pittvandewitt.viperfx || am broadcast -a android.intent.action.BOOT_COMPLETED -p com.pittvandewitt.viperfx
21+
PID=$(pidof $VIPERFXPACKAGE)
22+
[ -z "$PID" ] && am broadcast -a android.intent.action.BOOT_COMPLETED -p $VIPERFXPACKAGE
23+
[ -n "$PID" ] && echo -1000 > /proc/$PID/oom_score_adj
2124
sleep 15
2225
done
2326
) &

0 commit comments

Comments
 (0)