mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-04-26 22:13:32 -04:00
Fixed some more memory leaks.
This commit is contained in:
parent
bd575ad667
commit
26d2816071
5 changed files with 20 additions and 3 deletions
|
@ -315,6 +315,7 @@ self.onDebugWorldProgress = function onDebugWorldProgress(progress) {
|
|||
self.debugAbort = function () {
|
||||
if(self.debugWorld) {
|
||||
self.debugWorld.abort();
|
||||
self.debugWorld.destroy();
|
||||
self.debugWorld = null;
|
||||
}
|
||||
self.postMessage({type: 'debug-abort'});
|
||||
|
@ -379,6 +380,7 @@ self.onWorldLoaded = function onWorldLoaded() {
|
|||
var t3 = new Date();
|
||||
console.log("And it was so: (" + (diff / self.world.totalFrames).toFixed(3) + "ms per frame,", self.world.totalFrames, "frames)\nSimulation :", diff + "ms \nSerialization:", (t2 - t1) + "ms\nDelivery :", (t3 - t2) + "ms");
|
||||
self.world.goalManager.destroy();
|
||||
self.world.destroy();
|
||||
self.world = null;
|
||||
};
|
||||
|
||||
|
@ -410,6 +412,7 @@ self.abort = function abort() {
|
|||
if(self.world) {
|
||||
self.world.abort();
|
||||
self.world.goalManager.destroy();
|
||||
self.world.destroy();
|
||||
self.world = null;
|
||||
}
|
||||
self.postMessage({type: 'abort'});
|
||||
|
|
|
@ -31,6 +31,12 @@ module.exports = class Thang
|
|||
@addTrackedProperties ['exists', 'boolean'] # TODO: move into Systems/Components, too?
|
||||
#console.log "Generated #{@toString()}."
|
||||
|
||||
destroy: ->
|
||||
# Just trying to destroy __aetherAPIClone, but might as well nuke everything just in case
|
||||
@[key] = undefined for key of @
|
||||
@destroyed = true
|
||||
@destroy = ->
|
||||
|
||||
updateRegistration: ->
|
||||
system.register @ for system in @world.systems
|
||||
|
||||
|
@ -40,7 +46,7 @@ module.exports = class Thang
|
|||
|
||||
getGoalState: (goalID) ->
|
||||
@world.getGoalState goalID
|
||||
|
||||
|
||||
setGoalState: (goalID, status) ->
|
||||
@world.setGoalState goalID, status
|
||||
|
||||
|
|
|
@ -33,6 +33,13 @@ module.exports = class World
|
|||
@rand = new Rand 0 # Existence System may change this seed
|
||||
@frames = [new WorldFrame(@, 0)]
|
||||
|
||||
destroy: ->
|
||||
@goalManager?.destroy()
|
||||
thang.destroy() for thang in @thangs
|
||||
@[key] = undefined for key of @
|
||||
@destroyed = true
|
||||
@destroy = ->
|
||||
|
||||
getFrame: (frameIndex) ->
|
||||
# Optimize it a bit--assume we have all if @ended and are at the previous frame otherwise
|
||||
frames = @frames
|
||||
|
@ -109,6 +116,7 @@ module.exports = class World
|
|||
console.log(' Loaded', i, 'of', @totalFrames, "(+" + (t2 - @t0).toFixed(0) + "ms)")
|
||||
@t0 = t2
|
||||
continueFn = =>
|
||||
return if @destroyed
|
||||
if loadUntilFrame
|
||||
@loadFrames(loadedCallback,errorCallback,loadProgressCallback, skipDeferredLoading, loadUntilFrame)
|
||||
else
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
"firepad": "~0.1.2",
|
||||
"marked": "~0.3.0",
|
||||
"moment": "~2.5.0",
|
||||
"aether": "~0.2.0",
|
||||
"aether": "~0.2.8",
|
||||
"underscore.string": "~2.3.3",
|
||||
"firebase": "~1.0.2",
|
||||
"catiline": "~2.9.3",
|
||||
|
|
|
@ -65,7 +65,7 @@
|
|||
"redis": "",
|
||||
"webworker-threads": "~0.4.11",
|
||||
"node-gyp": "~0.13.0",
|
||||
"aether": "~0.2.3",
|
||||
"aether": "~0.2.8",
|
||||
"JASON": "~0.1.3",
|
||||
"JQDeferred": "~2.1.0"
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue