From 2f29b81027146fef73ffd8a245594f51c05ec1b4 Mon Sep 17 00:00:00 2001 From: wraitii Date: Sat, 14 Nov 2020 15:13:56 +0000 Subject: [PATCH] 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. --- source/simulation2/components/tests/test_scripts.h | 4 ++++ source/test_setup.cpp | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/source/simulation2/components/tests/test_scripts.h b/source/simulation2/components/tests/test_scripts.h index 3203a3599f..dcb3790644 100644 --- a/source/simulation2/components/tests/test_scripts.h +++ b/source/simulation2/components/tests/test_scripts.h @@ -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); diff --git a/source/test_setup.cpp b/source/test_setup.cpp index 2449c3fdb0..4c3dfb2ecc 100644 --- a/source/test_setup.cpp +++ b/source/test_setup.cpp @@ -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