diff --git a/core/scripts/run-tests.sh b/core/scripts/run-tests.sh
index fedc6b6fe9b64cfab772ef73c597c4285990369d..7e71112c7b2349a9e281a99367a5201c3318cf4e 100755
--- a/core/scripts/run-tests.sh
+++ b/core/scripts/run-tests.sh
@@ -16,7 +16,9 @@
 const SIMPLETEST_SCRIPT_COLOR_PASS = 32; // Green.
 const SIMPLETEST_SCRIPT_COLOR_FAIL = 31; // Red.
 const SIMPLETEST_SCRIPT_COLOR_EXCEPTION = 33; // Brown.
-const SIMPLETEST_SCRIPT_SQLITE_VARIABLE_LIMIT = 500;
+
+// Restricting the chunk of queries prevents memory exhaustion.
+const SIMPLETEST_SCRIPT_SQLITE_VARIABLE_LIMIT = 350;
 
 // Set defaults and get overrides.
 list($args, $count) = simpletest_script_parse_args();