Swapping is perfectly fine for the case where an app that has remained unused for a significant period of time starts being used again. It may even be faster than having the app manually release all of the memory it’s allocated and then manually reallocating it all again on user input (which is presumably what the alternative would be, if the complaint is only about the app’s memory usage when in an inactive state).
Free RAM is just RAM that’s doing nothing useful. Better to fill it with cached application states until you run out.
An application that genuinely uses less RAM at any point of its execution, whether that's measured by maximum RSS, average RSS, whatever, is still better. Then you can have more apps running at the same level of swapping. It's true that if you have a lot of free RAM, there's no need to split hairs. But what about when you don't have a lot? I was under the impression that computers should handle a billion Chrome tabs easily. Or like, y'know, workloads that people actually use that aren't always outlandish stress tests.
Sure, the ideal app uses no resources. But it really doesn’t matter how much allocated memory an app retains when in an unused state (if you’re running it on a modern multitasking OS). If there’s any memory pressure then those pages will get swapped out or compressed, and you won’t really notice because you’re not using the app.
It seems like you're saying that if the user acts in certain patterns, the OS will just take care of it. Isn't the point of computers and technology to make it so that users are less restricted and more empowered? If many people do actually notice performance issues particularly around usage of certain apps, then your recommended patterns are too narrow for practicality. You are talking about scenarios where there is no real pressure, the happy path, but that's not realistic.
I’m just saying that it would not make much difference if Electron reduced its idle memory usage. If you use an app infrequently, then it will get paged out and the memory it retains in its idle state will be available for other processes. If you use the app frequently then you care about active memory usage more than idle memory usage. Either way, there is not much to be gained by reducing idle memory usage. Any attempt to reduce it might just increase the wake up time of the app, which might then have to rebuild various data structures that could otherwise have been efficiently compressed or cached to disk by the OS.
You're still going off of a "happy path" mentality. The user decides when an app should be idle or active, not the OS. The OS therefore pages in and out with no grand scheme and may be out of sync with the user's next action. What of the time taken to page in an idle app's working set? Or, as I addressed from the start, what if the user wants many applications open and there is not much free memory? That means swapping becomes a necessity and not a luxury, performance drops, and user experience declines. I think there is plenty of, perhaps low-hanging is uncharitable, but not unreasonably high fruit to pick so that users can be more comfortable with whatever workload they desire. I don't think we're remotely pushing the limits of the technology here.
loading story #43130279