[Sprint  Galaxy Note 4 Original Android Development] ffolkes:
The amount of work and r&d I have been putting into the latest release of Plasma is mind boggling. So far the new kthreaded governor is working beautifully. In fact I have added and changed so much in zzmoove, I have renamed it 'warpcore' moving forward. People think Plasma kernel was abandoned, but it is very, very far from it. It is my endless goal to improve every aspect of the Note4 user experience.

Here's a rambling post about my most recent crazy experiment.

Lately I've been looking into RAM and memory management because of things that annoy me:

- Apps that get pushed out of RAM minutes after I was using them.

- Important apps that should always load instantly (keyboard, camera, phone dialer), but often don't because Android killed them.

- Viper4Android keeps getting killed while I listen to music.

- Various bluetooth services get killed while I listen to music, and cause the connection to drop out.

All of these can be fixed, but that'd have to be done at the ROM level before it was compiled. So instead I tried a different approach, and figured out how to block certain PIDs from the lowmemorykiller (LMK) driver within the kernel. Shortly after doing this I realized someone else did this a few years ago - there's even an app to help manage the protected PIDs. So I rewrote what I made to make it compatible with this app.

Unfortunately, as some of you may know (I did not), Android deals with "empty" (aka inactive) apps in several ways. a.) Via the LMK driver as mentioned above. This is what minfree and the oom_adj/oom_score_adj values you hear about are for. The feature above will now protect a PID from being killed by that driver. However, there are other things to worry about: b.) Android in userspace will only allow a certain number of apps to be inactive before automatically killing them. Fortunately this setting is very high out of the box, 32 I believe. c.) Android in userspace will only allow an app to lurk for 30 minutes - after that, it gets killed no matter what. This is very frustrating, since I had exempted the PIDs I wanted from the axe of the LMK, but now Android was deliberately killing them when there was no need to. Just because I haven't used the phone app in a few hours doesn't mean it needs be killed, especially if there is no free memory concern. So I decided to get crazy. Since I cannot do anything at the ROM level because it is already compiled, I had to look to the place within which I dwell - the kernel. After two days and about 30 experimental kernel builds, I figured out how to best intercept and ignore termination signals sent to processes via the process signalling system, which is at the core of the kernel. It took a while to figure out how to keep Android from crapping itself when it failed to kill something it thought it could, but things are more stable now. There was a side effect though, protected apps deliberately swiped from the recents screen wouldn't die. So I studied the logcats, and figured out a way to know when something was swiped off the list (vs. autokilled), and simultaneously release the protection on the app so it could indeed be killed.

Even with all these safeguards in place, I wanted to do more. So I added the ability to protect the last 5 used apps from both the LMK, and

Android's overzealous empty app killing mechanism. These protections are applied at the highest (or lowest, depending on how you look at it) level possible. The list is dynamically updated to always keep the last 5 used apps alive, even when Android wants to kill them. Besides, in low memory situations, there are plenty of other processes that can be killed to recover memory from.

A version that was developed for the mid-April CM 13 release is coming soon, and I hope to get other CM 13 versions to boot soon after. Then I plan to bring it to Marshmallow TW as well. :)