Do (and if not should) Browsers let a script know how much memory they are consuming?

I was thinking about doing a dynamic scrolling table. As the user scrolls down ajax loads in more rows to show. With the table I’m working on having the client load the whole thing would result in a page well north of 2 GB, so it isn’t feasable. I will probably end up putting some logical limits - hold say 100 rows total with 20 or so visible.

But it would be nice to make this decision based on memory available rather than a guess…

It’s not really exact, but you could start with closing your browser if you have it open, fire it up again, look at the task manager (or “top” in a *nix environment) how much memory it’s using on startup, go to the website, keep loading and see what happens to the memory usage.
That should at least give you an estimate to work with.

I’m afraid that Javascript provide no way for you to manage memory, or to find out that sort of information about the web browser.

A little off-topic, but I just wanted to say a big THANK YOU for considering the memory use !!

The amount of memory that most web pages use is getting ridiculous, and maybe part of the problem is that we don’t have good enough tools to monitor and adjust the memory use ? Any tips for javascript memory use will benefit everybody !

The scripts aren’t that big usually, but many use memory like they were the only web page available on the internet :slight_smile:

The scripts aren’t that big usually, but many use memory like they were the only web page available on the internet :slight_smile:

Wouldn’t that be because more complicated scripts are using more closures? Meaning vars declared in one place are kept in memory longer?

Closures can be a consideration, but as a contrast, reducing the number of global variables does go a long way to help reduce the amount of bloat.