Fix JS OOM in tests following aae417bd29

aae417bd29 made ScriptInterface not recreate a new JSContext since it
becomes a compartment wrapper, but that means we need to GC tests or
they might OOM.

To make it mostly seamless, GC on any test setup. The JS tests are
pretty close to the 16Mb limit as it stands so GC them manually too, for
good measure.

Refs #4893

Differential Revision: https://code.wildfiregames.com/D3101
This was SVN commit r24182.
This commit is contained in:
wraitii 2020-11-14 15:13:56 +00:00
parent aa15066c69
commit 2f29b81027
2 changed files with 12 additions and 0 deletions

View File

@ -19,6 +19,8 @@
#include "ps/Filesystem.h"
#include "scriptinterface/ScriptContext.h"
class TestComponentScripts : public CxxTest::TestSuite
{
public:
@ -89,6 +91,8 @@ public:
paths.push_back(VfsPath(L"simulation/components/tests/setup_test.js"));
for (const VfsPath& path : paths)
{
// Clean up previous scripts.
g_ScriptContext->ShrinkingGC();
CSimContext context;
CComponentManager componentManager(context, g_ScriptContext, true);

View File

@ -94,6 +94,14 @@ class MiscSetup : public CxxTest::GlobalFixture
return true;
}
virtual bool setUp()
{
// Clean up any JS leftover between tests.
g_ScriptContext->ShrinkingGC();
return true;
}
private:
// We're doing the initialization and shutdown of the ScriptEngine explicitly here