How do you detect memory limits in JavaScript?

Can browsers enforce any sort of limit on the amount of data that can be stored in JavaScript objects? If so, is there any way to detect that limit?

It appears that by default, Firefox does not:

var data;
$("document").ready(function() {
  data = [];
  for(var i = 0; i < 100000000000; i++) {

That continues to consume more and more memory until my system runs out.

Since we can’t detect available memory, is there any other way to tell we are getting close to that limit?


The application I’m developing relies on very fast response times to be usable (it’s the core selling point). Unfortunately, it also has a very large data set (more than will fit into memory on weaker client machines). Performance can be greatly improved by preemptively loading data strategically (guessing what will be clicked). The fallback to loading the data from the server works when the guesses are incorrect, but the server round trip isn’t ideal. Making use of every bit of memory I can makes the application as performant as possible.

Right now, it works to allow the user to “configure” their performance settings (max data settings), but users don’t want to manage that. Also, since it’s a web application, I have to handle users setting that per computer (since a powerful desktop has a lot more memory than an old iPhone). It’s better if it just uses optimal settings for what is available on the systems. But guessing too high can cause problems on the client computer too.

155 thoughts on “How do you detect memory limits in JavaScript?”

  1. Pingback: free viagra
  2. Pingback: buy viagra
  3. Pingback: cialis australia
  4. Pingback: cialis 20mg
  5. Pingback: cialis ingredients
  6. Pingback: sildenafil
  7. Pingback: sildenafil 50mg uk
  8. Pingback: cialis mexico
  9. Pingback: snorting viagra
  10. Pingback: otc viagra
  11. Pingback: viagra for women
  12. Pingback: natural viagra
  13. Pingback: viagra dosage
  14. Pingback: viagra jokes
  15. Pingback: viagra cialis
  16. Pingback: viagra connect

Leave a Comment