Clears the AVM1 stack after executing bytecode
AVM1 bytecode may leave the operand stack unbalanced, and this will cause a slow memory leak if the stack is never cleared.
This commit is contained in:
parent
c6bd431864
commit
3b1c981d25
|
@ -314,6 +314,10 @@ impl<'gc> Avm1<'gc> {
|
||||||
self.stack.len()
|
self.stack.len()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn clear_stack(&mut self) {
|
||||||
|
self.stack.clear()
|
||||||
|
}
|
||||||
|
|
||||||
pub fn push(&mut self, value: Value<'gc>) {
|
pub fn push(&mut self, value: Value<'gc>) {
|
||||||
avm_debug!(self, "Stack push {}: {value:?}", self.stack.len());
|
avm_debug!(self, "Stack push {}: {value:?}", self.stack.len());
|
||||||
self.stack.push(value);
|
self.stack.push(value);
|
||||||
|
|
|
@ -1661,6 +1661,10 @@ impl Player {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AVM1 bytecode may leave the stack unbalanced, so do not let garbage values accumulate
|
||||||
|
// across multiple executions and/or frames.
|
||||||
|
context.avm1.clear_stack();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue