aboutsummaryrefslogtreecommitdiff
path: root/src/framework.js
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2011-11-29 17:23:32 -0800
committerAlon Zakai <alonzakai@gmail.com>2011-11-29 17:23:32 -0800
commitff7d01a6a846dd9a976dc7e3c585b074def23497 (patch)
tree1e666a7a41d664f4799630a652a6a8ba46e95665 /src/framework.js
parentf8c5d678ecd79b4e81c82f7e847f5cf6d6007f34 (diff)
more memory debugging stuff, and a disabled option to throttle the framework inbox
Diffstat (limited to 'src/framework.js')
-rw-r--r--src/framework.js14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/framework.js b/src/framework.js
index 6e2bbe81..d830599d 100644
--- a/src/framework.js
+++ b/src/framework.js
@@ -22,6 +22,7 @@ var MemoryDebugger = {
MemoryDebugger.datas = {};
var info = MemoryDebugger.doGC();
MemoryDebugger.last = info[2];
+ MemoryDebugger.max = 0;
MemoryDebugger.tick('--clear--');
},
@@ -44,6 +45,7 @@ var MemoryDebugger = {
var info = MemoryDebugger.doGC();
var before = info[1];
var after = info[2];
+ MemoryDebugger.max = Math.max(MemoryDebugger.max, before, after);
// A GC not called by us may have done some work 'silently'
var garbage = before - after;
var real = after - MemoryDebugger.last;
@@ -70,6 +72,7 @@ var MemoryDebugger = {
dump: function() {
var vals = values(MemoryDebugger.datas);
+ print('zz max: ' + (MemoryDebugger.max/(1024*1024)).toFixed(3));
print('zz real:');
vals.sort(function(x, y) { return y.real - x.real });
vals.forEach(function(v) { if (Math.abs(v.real) > 1024*1024) print('zz ' + v.name + ' real = ' + (v.real/(1024*1024)).toFixed(3) + ' mb'); });
@@ -115,8 +118,15 @@ Substrate.prototype = {
this.currUid ++;
}
}
- actor.inbox = [];
- actor.items = actor.items.concat(items);
+ var MAX_INCOMING = Infinity;
+ if (MAX_INCOMING == Infinity) {
+ actor.inbox = [];
+ actor.items = actor.items.concat(items);
+ } else {
+ throw 'Warning: Enter this code at your own risk. It can save memory, but often regresses speed.';
+ actor.inbox = items.slice(MAX_INCOMING);
+ actor.items = actor.items.concat(items.slice(0, MAX_INCOMING));
+ }
},
addActor: function(name_, actor) {