I'm just making up a scenario, but let's say I have a 500MB file that I want to provide an html table for the client to view the data. Let's say there are two scenarios:
Ignoring things like pagination or virtual tables, I'm just concerned about "if the full dataset can fit in the user's available memory". Is this possible to detect in a browser (even with a user's confirmation). If so, how could this be done?
This answer has been answered about 6 years ago, and the question points to an answer from 10 years ago. I'm wondering what the current state is, as browsers have changed quite a bit since then and there's also webassembly and such.
The Task Manager is a realtime monitor that tells you how much memory a page is currently using. Press Shift+Esc or go to the Chrome main menu and select More tools > Task manager to open the Task Manager. Right-click on the table header of the Task Manager and enable JavaScript memory.
The quickest way to do this is to type "Diagnostics" in ChromeOS' search bar, and then hit "Diagnostics" in the page that comes up. Once there, at the bottom, you'll see RAM information.
Your computer uses RAM as a cache to store things it may need again soon—in the case of web browsers, that could be web pages or other resources used by plug-ins and extensions. That way, when you go back to that web page or use that extension again, it'll load faster. This is a good thing.
So as a rule of thumb I would recommend staying below 150-200 MB of memory. GMail takes up ~100MB of memory on Chrome for Linux, so I think that keeping up with GMail is a reasonable goal. Another benefit of keeping memory usage relatively low is that your users can more easily view your site on a smartphone.
Use performance.memory.usedJSHeapSize
. Though it non-standard and in development, it will be enough for testing the memory used. You can try it out on edge/chrome/opera, but unfortunately not on firefox or safari (as of writing).
Attributes (performance.memory
)
jsHeapSizeLimit
: The maximum size of the heap, in bytes, that is available to the context.
totalJSHeapSize
: The total allocated heap size, in bytes.
usedJSHeapSize
: The currently active segment of JS heap, in bytes.
Read more about performance.memory
: https://developer.mozilla.org/en-US/docs/Web/API/Performance/memory.
CanIUse.com: https://caniuse.com/mdn-api_performance_memory
CanIUse.com 2020/01/22
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With