Memory Manager <---> Application Two Way API
Hi, I have noticed these days that application developers tend to go the route of use up as much memory as possible. A lot of it makes sense, why reload off of disk, over the Internet, etc. when you can just stick it in RAM? The problem I see a lot are applications tend to take up huge amounts of memory (sometimes it is hard to say how much is caching as opposed to unintentional memory leaks) and fill up the swap partition. The question comes up if the vast majority of that space is just being used to cache stuff in memory uncompressed and in rapid access space, why spend all kinds of time scattering it about the swap partition and then pulling all of those scattered chucks back off the hard disk? Why not instead have the operating system's memory manager and applications running on top of the OS coordinate so that applications can hog up RAM when there is RAM to spare and then trim back when more efficient uses for those chunks of RAM are found? For example let's say you are running a window manager, a web browser, and a database engine. The window manager decides to cache a wide range of images so if that if an image is requested again it can pull it right out of memory very quickly. The web browser renders all of the web pages it comes across and sticks it into memory. Why spend all kinds of time re-rendering recently visited web pages if you can just cache it all in memory. The database engine decides all these tables take time to load from disks and it takes an appreciable amount of time to run all these queries. Why not just cache these tables in memory and store the results of these queries in memory in case they are asked for again in the near future. Now you set all of this lose on a system for an extended period of time and before you know it each program is using hundreds of megabytes or even gigabytes of memory and all totaled up is much more than the physical RAM in the system. When you select the web browser it takes forever to load up a page because instead of just re-redering it (which only took a second or two in the first pace) it has to rummage about the swap partition to find all of the fragments of the previously rendered page. Then you try to use the database. Well there is no free RAM for the database to operate because the web browser is hogging it all up so a large portion of the web browser needs to be dumped to disk. Then the database goes well I have all this cached stuff, I think I will use that, but it gets tricked because all of that cached stuff is strewn about the swap partition and it actually takes longer to pull all the fragments off of the swap partition than it does to just re-read off of disk and recompute. Then when you try use use the window manager the same sort of deal crops up except you have had two other applications fighting over RAM before hand while it sat idle so it is completely and totally out on the swap partition and takes even longer to come up. So in the end all of the tricks employed that should speed things up are actually working against you to dramatically slow things down. --Jason Snyder--
participants (1)
-
Jason Snyder