Skip to content

Instantly share code, notes, and snippets.

@fuentesjr
Last active June 27, 2016 14:15
Show Gist options
  • Select an option

  • Save fuentesjr/74fcc512efff4a62d037a0adc9948e59 to your computer and use it in GitHub Desktop.

Select an option

Save fuentesjr/74fcc512efff4a62d037a0adc9948e59 to your computer and use it in GitHub Desktop.
gc_demo
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>GC Test</title>
<style>
html { background-color: beige }
</style>
</head>
<body>
Hello GC World!
<script type="text/javascript" src="gc.js"></script>
</body>
</html>
//var sizeof = require('object-sizeof');
var BYTES_IN_MB = 1024 * 1024;
var numObjsInMb = (BYTES_IN_MB/10)|0;
function Point1D(val) {
this.x = val;
}
//var totalSize = 0;
var x = [];
var m;
var numIntervals = 0;
var allocID = setInterval(function() {
console.log("interval=", numIntervals);
numIntervals += 1;
/*
if (false && numIntervals > 5 ) {
clearInterval(intervalID);
console.log("Done!");
}
*/
for(var i = 0; i < numObjsInMb; i++) {
m = new Point1D(0); //totalSize += parseInt(BYTES_IN_OBJ, 10);
x.push(m);
}
}, 200);
var cleanupID = setInterval(function() {
x = [];
}, 5000);
//print("BytesInMB=" + BYTES_IN_MB.toString() + " totalSize=" + totalSize.toString());
//console.log("BytesInMB=" + BYTES_IN_MB.toString() + " totalSize=" + totalSize.toString());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment