Michelasso wrote:
Let me understand, because this point of yours has never been clear to me. Are you saying that Safari is practically caching in RAM the Internet content of the old pages?
It isn't that simple. A web page is really just a series of elements & a set of instructions that tells the browser what to do with them. (Safari has several tools to show you this, including View Source, the Activity window, & the various 'show' items in the Develop menu.)
So if say a browser encounters an instruction to run a Javascript, then the browser must load & initialize its code to do that, create any buffers or other work space that task needs, & so on. Some of the work is passed on to OS level API's, but it still has to set up the variables & such to pass to the API, gather any info or signals the API passes back to it, etc. Likewise, an instruction might say to fetch a series of image elements (pngs, gifs, jpegs, whatever) & display them, link some of them to button scripts, & so on.
All of this requires memory. Some of it can be reused. For example, if some of the static image elements (like say the ones that are used to construct the Apple header at the top of this page) are used on multiple pages, then they don't need to be downloaded & reconstructed on each page view if they are still in memory from a previously viewed page. The same goes for initialized code elements that run the instructions. Only the elements that are unique to the web page, change on reload, or have not previously been encountered must be processed before the new page can be rendered.
This is a very simplified explanation of a topic that can fill books so you will need to consult other sources to understand the details of how it actually works, but the essential point is that web pages are built in memory from many different parts & some of them can be reused, along with the code used to build them. This goes much faster if these elements are already in real memory (RAM) than if they have to be reloaded from the backing store, from system files, or downloaded again from the Internet, so the memory manager will try to keep them in RAM if there is room for that.
Having a slow internet connection, like mine, to cache data in RAM is just a waste of resources with no benefits.
On the contrary, if every element of a web page had to be downloaded every time it was encountered again, web pages would take much longer to load over a slow connection.
Still I don't understand how some people report Safari Web Content process using only 150MB with 15 or more tabs open after few hours working. I've seen the Activity Monitor screenshots, I couldn't believe my eyes. Mine goes to 300MB just after launching it.
As has been mentioned here many times, the amount of real memory an app uses depends on how much RAM is installed in the Mac, on what tasks the app has done previously, & on the demand for real memory from other running processes. Those other processes include both other apps launched by users & various root & other non-human user processes that run on their own schedule. Most processes are "faceless" (no UI) & may support per-user or system-wide tasks that other processes require.
Complicating things that much more, processes may share memory, which can be inherited from a parent process, read from or written to by two or more processes, & used for things like fast interapplication communication or sharing icons or other resources.
If you don't understand & consider all these interrelated factors -- or have the details necessary to do so from the various reports -- there is no way you will be able to tell if Safari (or any other app or system process) is using memory correctly.
The numbers you get from Activity Monitor & similar tools only tell you a small part of what you need to do this. You can't just look at say the real memory used by a process & know if it is too large or not. To determine that, you need to know the details of what the process does & how it does it, how it asks the OS to allocate & free whatever memory it uses, what other processes might also be sharing a part of its memory or asking for memory of their own, & all the rest of it. Much of this requires the use of tools that actually show how memory is used within a specific process; some of it requires access to the source code of the app or at least its symbol table. Otherwise, you basially are trying to figure out how something works without any idea of what its internal structure is or what its parts do.
If this were about some other complex device, say a car or TV, I think it would be obvious to most people why this is so. I don't understand why some people think it is any less applicable to a computer, arguably the most complex device most of us ever use.