Run GC frequently in the simulation script context, to keep memory usage down
This was SVN commit r8622.
This commit is contained in:
parent
58a95ba95c
commit
13d2e44ff5
@ -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
|
||||
{
|
||||
|
@ -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);
|
||||
|
@ -214,6 +214,12 @@ bool CSimulation2Impl::Update(int turnLength, const std::vector<SimulationComman
|
||||
// if (m_TurnNumber == 0)
|
||||
// m_ComponentManager.GetScriptInterface().DumpHeap();
|
||||
|
||||
// Run the GC occasionally
|
||||
// (TODO: we ought to schedule this for a frame where we're not
|
||||
// running the sim update, to spread the load)
|
||||
if (m_TurnNumber % 10 == 0)
|
||||
m_ComponentManager.GetScriptInterface().MaybeGC();
|
||||
|
||||
if (m_EnableOOSLog)
|
||||
DumpState();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user