Skip to content

Commit f0f1a20

Browse files
committed
Improve memory limit test
1 parent c5facf0 commit f0f1a20

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

tests/set_memory_limit_001.phpt

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,21 @@ if (getenv("SKIP_SLOW_TESTS")) {
1313

1414
$JS = <<< EOT
1515
var jsfunc = function() {
16-
var text = "abcdefghijklmnopqrstuvwyxz0123456789";
16+
var text = "abcdefghijklmnopqrstuvwyxz0123456789"; // 36 bytes fits 277777 times in 10 MB
1717
var memory = "";
18-
for (var i = 0; i < 100; ++i) {
19-
for (var j = 0; j < 10000; ++j) {
18+
19+
// this should exceed the memory limit as it tries to generate 300_000 * 36 bytes = 10.8 MB
20+
for (var i = 0; i < 30; ++i) {
21+
for (var j = 0; j < 10_000; ++j) {
2022
memory += text;
21-
}
22-
sleep(0);
23+
}
2324
}
2425
};
2526
jsfunc;
2627
EOT;
2728

2829
$v8 = new V8Js();
29-
$v8->setMemoryLimit(10000000);
30+
$v8->setMemoryLimit(10_000_000);
3031

3132
$func = $v8->executeString($JS);
3233
var_dump($func);

0 commit comments

Comments
 (0)