One of the jobs of the Linux kernel—and all operating system
kernels—is to manage the resources available to the system. When those resources
get used up, what should it do? If the resource is RAM, there's not much
choice. It's not feasible to take over the behavior of any piece of user
software, understand what that software does, and make it more memory-efficient. Instead, the kernel has very little choice but to try to
identify the software that is most responsible for using up the system's
RAM and kill that process.