5 ms·
The browser would have to save the source text for EVERY tab it opens, regardless of whether you view source or not. That seems more onerous than making a separ
by morley 10y ago
The browser would have to save the source text for EVERY tab it opens, regardless of whether you view source or not. That seems more onerous than making a separate request for the source code every once in a while.
- amelius 10y agoYes, but if you have more than enough memory, then that's no problem. So, the browser should load the HTML page into a part of memory that can be discarded by the OS if the OS needs more memory. Actually I think it is strange that no such memory API exists in Unix. EDIT: Anyway, storing it in the browser's file cache would also do the trick, I suppose :)
- Insanity 10y agoIsn't that one of the issues nowadays, that people have the attitude "we have enough memory" and thus don't tend to care about optimizing for memory usage anymore. Your suggested solution, about discarding when memory is needed, solves this problem. But it solves a problem that would be created by needlessly storing a lot more data than needed. So it's a solution to a problem that was not a problem to begin with. But I know, if it's a few kb, it will not make a huge difference.
- kahnpro 10y agoSo hide it behind a feature flag?
- user5994461 10y ago> "we have enough memory" Your phone is in disagreement.
- dagw 10y agoMy phone has a quite insane 3 GB of RAM.
- user5994461 10y agoThe most common $150 phone from last year only has 1GB, half of which is reserved for the OS.
- mbertschler 10y agoMy phone also has the insane 3GB of RAM, but last week Chrome killed Spotify and vice versa (music stopped playing) as soon as I switched apps. Sadly 3GB is not enough for Android and todays apps.
- deleted 10y ago[deleted]
- Fnoord 10y agoWe're talking about a default feature which is disabled 'for average users'. Average users only have a few tabs open in their browser. Not 100. Average users also don't have 3 GB RAM, nor do they use view source on a mobile phone, and neither do average users actually use the feature. So the default setting makes sense even though a user who is using the feature may end up using several MB due to a reload (not cool on a plan). If you are saving 57 kB per tab open, that'd be ~5,7 MB with 100 tabs open. But if you have 100 tabs open on a mobile phone (!!), you have a bigger problem, and all those tabs are causing swapping already anyway. In that sense, enabling the feature by default makes sense. And don't forget that some people don't have flat rate internet.
- iLoch 10y ago100kb * 100 tabs is 10MB. I'll take my chances.
- tmd83 10y agoNo this is really not the case of thinking we have enough memory. This is the realization that the static source code of a page is a percentage error compared to the memory overhead of a rendered page. The modern browser are memory hog I would rather they focus on that. Its also a broken implementation function wise since I have asked for the source of the current page not of a reload.
- r721 10y agoSimilar "tab discarding" feature already exists in Chrome, by the way: https://developers.google.com/web/updates/2015/09/tab-discarding https://developers.google.com/web/updates/2015/09/tab-discar...
- tomtomtom777 10y ago> So, the browser should load the HTML page into a part of memory that can be discarded by the OS if the OS needs more memory. Actually I think it is strange that no such memory API exists in Unix. It is more tricky then you would think to determine what "needed" memory means. Does the OS need disk cache? Or the content of memory mapped files? It's not unlikely that you currently have some process active which has memory mapped a huge file. Does it need the content? Who knows.
- evilDagmar 10y agoYou are talking about an OS-provided cache for the browser to store it's own cache in? There's little sense in that.
- Kiwikwi 10y agoMoving memory management into the OS often makes sense, because the OS has the big cross-application picture, knows the system-wide memory pressure, and most importantly, already manages the memory of applications, by swapping between RAM and disk. For the same reason, OS X and Android Linux both have systems for OS managed caches, and AFAIK Firefox already uses these: https://bugzilla.mozilla.org/show_bug.cgi?id=748598 https://bugzilla.mozilla.org/show_bug.cgi?id=748598 The status on mainline Linux is a bit more nebulous (seems Android's ashmem has been upstreamed, but it's not directly usable on GNU/Linux systems?), and other efforts have stranded: https://lwn.net/Articles/602650/ https://lwn.net/Articles/602650/ For some more thoughts about memory management on OS level vs. application level, I can recommend this "random outburst" from the designer of the Varnish HTTP cache: https://www.varnish-cache.org/docs/trunk/phk/notes.html https://www.varnish-cache.org/docs/trunk/phk/notes.html
- threeseed 10y agoAm I in some parallel universe here ? We are talking about hundreds of KBs of memory total which is nothing and if it's a worry for mobile devices we have the disk. It's not a feature that demands instant performance.
- heartbreak 10y ago> It's not a feature that demands instant performance. Hence it's acceptable to request the document from the server when opening 'View Source'.
- gbog 10y agoNo, because when you want to view the source you mean to view the source of this very document, not the source you'd get by asking to reload the page, it is often different.
- sp332 10y agoIf you want to see the page as it's currently being rendered, looking in the developer tools seems more relevant anyway.
- evilDagmar 10y agoIf they wanted that, they'd have looked at the developer tools to begin with. Many of you folks are completely missing the point. The world wide web took off in large part because it was incredibly easy to learn HTML, because with every webpage if one wanted to know how it worked one could just look at the source code. How the page is currently being rendered, what state the DOM might be in... These things do not matter to someone trying to view the source HTML for a page. They're looking to learn about the HTML. They're not goimg to get that by viewing pre-digested DOM information.
- speeder 10y agoOr a website I was trying to fix: the source in view source, and thr stuff on dev tools, never matched each other, even with JS disabled. in the end after days I gave up and the page is in production, crazy bugs and all, because I can't figure why on both chrome and Firefox the webpage end with lots of random "strong" and "span" tags that don't exist anywhere in the original source. The tags aren't even closed properly, some are never closed, some are closed multiple times.
- godzilla82 10y agoBut the amount of memory required for plain text source is very small compared to the memory allocated to render the page.