Skip to content

Instantly share code, notes, and snippets.

@thecountofzero
Last active December 29, 2015 05:39
Show Gist options
  • Save thecountofzero/7623459 to your computer and use it in GitHub Desktop.
Save thecountofzero/7623459 to your computer and use it in GitHub Desktop.
Memory Leak Test
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Memory Leak Test</title>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<div id="dummy"><button id="btn">Stop Polling</button></div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js"></script>
<script src="can.jquery.js"></script>
<script src="http://canjs.com/release/latest/can.construct.proxy.js"></script>
<script src="http://canjs.com/release/latest/can.fixture.js"></script>
<script src="http://canjs.com/release/latest/can.object.js"></script>
<script type='text/javascript'>
$(document).ready(function() {
var Thing = can.Model.extend({
id: "name",
findAll: "GET /things"
}, {});
can.fixture('GET /things', function() { return [{"name": "Sox", "externalName": "Sox", "serialNumber": "feca818eba1da7c3", "policy": "Baseball", "cache": "Cache 0", "pool": "S3", "blocks": "2097152", "blockSize": "512", "megabytes": "1024", "state": "operating", "healthState": "online", "flushEnabled": "1", "flushStart": "2013-Nov-23 22:42:37.831163", "flushDone": "2013-Nov-23 22:42:37.897936", "pageStats": {"page_size": "2048", "dirty": "0", "to_flush": "0", "flushed": "0"}, "tags": {}, "sparse": {"object": "d113e674-5157-11e3-8ae9-047d7b17a90d-mdop6qsfyhc9t", "regions": "0", "pages_per_region": "1024", "page_size": "2048"}, "snapshotPending": "0", "snapshotPendingTotalPages": "0", "snapshotPendingPagesFlushed": "0", "snapshots": [], "compression": {"recent": "0", "total": "0"}, "additionalSnapshotDetails": null, "clients": []}, {"name": "white.cifsvol", "externalName": "white.cifsvol", "serialNumber": "bd57fa7bb3874c53", "policy": "Baseball", "cache": "Cache 0", "pool": "S3", "blocks": "2097152", "blockSize": "512", "megabytes": "1024", "state": "operating", "healthState": "online", "flushEnabled": "1", "flushStart": "2013-Nov-23 22:42:37.831133", "flushDone": "2013-Nov-23 22:42:37.897943", "pageStats": {"page_size": "2048", "dirty": "0", "to_flush": "0", "flushed": "0"}, "tags": {"share": "white"}, "sparse": {"object": "b688445c-52de-11e3-b0a0-047d7b17a90d-65nv0tc0aj9jh", "regions": "1", "pages_per_region": "1024", "page_size": "2048"}, "snapshotPending": "0", "snapshotPendingTotalPages": "0", "snapshotPendingPagesFlushed": "0", "snapshots": [], "compression": {"recent": "0.00172622", "total": "0.00172622"}, "additionalSnapshotDetails": null, "clients": []}, {"name": "Blue Sox", "externalName": "Sox", "serialNumber": "feca818eba1da7c3", "policy": "Baseball", "cache": "Cache 0", "pool": "S3", "blocks": "2097152", "blockSize": "512", "megabytes": "1024", "state": "operating", "healthState": "online", "flushEnabled": "1", "flushStart": "2013-Nov-23 22:42:37.831163", "flushDone": "2013-Nov-23 22:42:37.897936", "pageStats": {"page_size": "2048", "dirty": "0", "to_flush": "0", "flushed": "0"}, "tags": {}, "sparse": {"object": "d113e674-5157-11e3-8ae9-047d7b17a90d-mdop6qsfyhc9t", "regions": "0", "pages_per_region": "1024", "page_size": "2048"}, "snapshotPending": "0", "snapshotPendingTotalPages": "0", "snapshotPendingPagesFlushed": "0", "snapshots": [], "compression": {"recent": "0", "total": "0"}, "additionalSnapshotDetails": null, "clients": []}, {"name": "yellow.cifsvol", "externalName": "white.cifsvol", "serialNumber": "bd57fa7bb3874c53", "policy": "Baseball", "cache": "Cache 0", "pool": "S3", "blocks": "2097152", "blockSize": "512", "megabytes": "1024", "state": "operating", "healthState": "online", "flushEnabled": "1", "flushStart": "2013-Nov-23 22:42:37.831133", "flushDone": "2013-Nov-23 22:42:37.897943", "pageStats": {"page_size": "2048", "dirty": "0", "to_flush": "0", "flushed": "0"}, "tags": {"share": "white"}, "sparse": {"object": "b688445c-52de-11e3-b0a0-047d7b17a90d-65nv0tc0aj9jh", "regions": "1", "pages_per_region": "1024", "page_size": "2048"}, "snapshotPending": "0", "snapshotPendingTotalPages": "0", "snapshotPendingPagesFlushed": "0", "snapshots": [], "compression": {"recent": "0.00172622", "total": "0.00172622"}, "additionalSnapshotDetails": null, "clients": []}, {"name": "Sitter", "externalName": "Sox", "serialNumber": "feca818eba1da7c3", "policy": "Baseball", "cache": "Cache 0", "pool": "S3", "blocks": "2097152", "blockSize": "512", "megabytes": "1024", "state": "operating", "healthState": "online", "flushEnabled": "1", "flushStart": "2013-Nov-23 22:42:37.831163", "flushDone": "2013-Nov-23 22:42:37.897936", "pageStats": {"page_size": "2048", "dirty": "0", "to_flush": "0", "flushed": "0"}, "tags": {}, "sparse": {"object": "d113e674-5157-11e3-8ae9-047d7b17a90d-mdop6qsfyhc9t", "regions": "0", "pages_per_region": "1024", "page_size": "2048"}, "snapshotPending": "0", "snapshotPendingTotalPages": "0", "snapshotPendingPagesFlushed": "0", "snapshots": [], "compression": {"recent": "0", "total": "0"}, "additionalSnapshotDetails": null, "clients": []}, {"name": "dummy", "externalName": "white.cifsvol", "serialNumber": "bd57fa7bb3874c53", "policy": "Baseball", "cache": "Cache 0", "pool": "S3", "blocks": "2097152", "blockSize": "512", "megabytes": "1024", "state": "operating", "healthState": "online", "flushEnabled": "1", "flushStart": "2013-Nov-23 22:42:37.831133", "flushDone": "2013-Nov-23 22:42:37.897943", "pageStats": {"page_size": "2048", "dirty": "0", "to_flush": "0", "flushed": "0"}, "tags": {"share": "white"}, "sparse": {"object": "b688445c-52de-11e3-b0a0-047d7b17a90d-65nv0tc0aj9jh", "regions": "1", "pages_per_region": "1024", "page_size": "2048"}, "snapshotPending": "0", "snapshotPendingTotalPages": "0", "snapshotPendingPagesFlushed": "0", "snapshots": [], "compression": {"recent": "0.00172622", "total": "0.00172622"}, "additionalSnapshotDetails": null, "clients": []}] });
var timeoutID,
poll = function() {
Thing.findAll().always(function(things) {
timeoutID = setTimeout(function() {
poll();
}, 10000);
});
};
$('#btn').click(function() {
clearTimeout(timeoutID);
})
poll();
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment