diff --git a/source/scriptinterface/ScriptInterface.cpp b/source/scriptinterface/ScriptInterface.cpp index 694dce1321..416de46c4c 100644 --- a/source/scriptinterface/ScriptInterface.cpp +++ b/source/scriptinterface/ScriptInterface.cpp @@ -777,6 +777,10 @@ void ScriptInterface::DumpHeap() fprintf(stderr, "# Bytes allocated after GC: %d\n", JS_GetGCParameter(m->m_rt, JSGC_BYTES)); } +void ScriptInterface::MaybeGC() +{ + JS_MaybeGC(m->m_cx); +} class ValueCloner { diff --git a/source/scriptinterface/ScriptInterface.h b/source/scriptinterface/ScriptInterface.h index 1afa156391..bcc24b0f18 100644 --- a/source/scriptinterface/ScriptInterface.h +++ b/source/scriptinterface/ScriptInterface.h @@ -253,6 +253,8 @@ public: }; #define LOCAL_ROOT_SCOPE LocalRootScope scope(GetContext()); if (! scope.OK()) return false + void MaybeGC(); + private: bool CallFunction_(jsval val, const char* name, size_t argc, jsval* argv, jsval& ret); bool Eval_(const char* code, jsval& ret); diff --git a/source/simulation2/Simulation2.cpp b/source/simulation2/Simulation2.cpp index b782f84407..8a5a0d9f33 100644 --- a/source/simulation2/Simulation2.cpp +++ b/source/simulation2/Simulation2.cpp @@ -214,6 +214,12 @@ bool CSimulation2Impl::Update(int turnLength, const std::vector