Created
April 4, 2015 18:27
-
-
Save dvingo/4cf38786ded7761941df to your computer and use it in GitHub Desktop.
create a large number of string objects in js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset='utf-8'> | |
<title>How much memory?</title> | |
</head> | |
<body> | |
<h1>How many JS object can we put in an array?</h1> | |
<script> | |
var x = []; | |
var count = 10000000; | |
var data = ""; | |
var i; | |
for (i=0;i<count;i++) { | |
data += "a"; | |
x.push({key:data}); | |
} | |
setInterval(function() { | |
console.log('We have data: ', x.length); | |
console.log('x: ', x[count-1]); | |
console.log('data[0]: ', data[0]); | |
console.log('data.length: ', data.length); | |
}, 1000) | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment