No need to patch, compile or otherwise change anything in code, you can adjust oom kill likelyhood per-process using a sysctl tunable, or better let systemd do it for you.
Of you search some more you will find the issue is not that simple though, as there are several different memory pressure systems in place on SFOS, (the kernel oom, the mce one, the Android one at least) and finding the right tuning for all of them isn’t trivial.