mirror of
https://github.com/bdnugget/php-src.git
synced 2026-11-07 09:17:29 +00:00
Don't automatically adjust memory_limit to 2M
As PHP has a minimum memory usage of 2M (size of allocator chunk), setting a limit below that value is not meaningful and will be automatically rounded up to the chunk size. Rather than doing this silently, show the newly introduced error message. The memory limit had to be increased to 2M for a number of tests. tests/lang/bug45392 has been marked as XFAIL. This old bugfix is not working as intended. The memory limit in main's `PG(memory_limit)` differs from the one in zend_alloc. In zend_alloc the `AG(mm_heap)->limit` is defined as `max(passed_value, ZEND_MM_CHUNK_SIZE)`. The check made in an unclean shutdown will never be true unless the memory limit is lower than ZEND_MM_CHUNK_SIZE, which happened to be the case in the test. https://bugs.php.net/bug.php?id=45392 https://github.com/php/php-src/commit/fcc0fdd125fdb9e1713f91d027fe07d680a0cf36
This commit is contained in:
1 parent
1aafed5e98
commit
3a4ea6cb91
6 files changed
+8
-9
No files matched your search
@@ -1,7 +1,7 @@
|
||||
--TEST--
|
||||
Out of Memory in a fiber
|
||||
--INI--
|
||||
memory_limit=10K
|
||||
memory_limit=2M
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (getenv("USE_ZEND_ALLOC") === "0") {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
--TEST--
|
||||
Out of Memory in a nested fiber
|
||||
--INI--
|
||||
memory_limit=10K
|
||||
memory_limit=2M
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (getenv("USE_ZEND_ALLOC") === "0") {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
--TEST--
|
||||
Out of Memory from recursive fiber creation
|
||||
--INI--
|
||||
memory_limit=10K
|
||||
memory_limit=2M
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (getenv("USE_ZEND_ALLOC") === "0") {
|
||||
|
||||
@@ -2661,9 +2661,6 @@ ZEND_API char* ZEND_FASTCALL zend_strndup(const char *s, size_t length)
|
||||
ZEND_API zend_result zend_set_memory_limit(size_t memory_limit)
|
||||
{
|
||||
#if ZEND_MM_LIMIT
|
||||
if (memory_limit < ZEND_MM_CHUNK_SIZE) {
|
||||
memory_limit = ZEND_MM_CHUNK_SIZE;
|
||||
}
|
||||
if (UNEXPECTED(memory_limit < AG(mm_heap)->real_size)) {
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
--TEST--
|
||||
Bug #78902: Memory leak when using stream_filter_append
|
||||
--INI--
|
||||
memory_limit=512k
|
||||
memory_limit=2M
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
/** create temporary file 2mb file */
|
||||
$tmp_file_name = tempnam(sys_get_temp_dir(), 'test_');
|
||||
$fp = fopen($tmp_file_name, 'w+');
|
||||
$size = 1024 * 1024 * 2; // 2mb
|
||||
$size = 1024 * 1024 * 2; // 2mb, larger than the memory limit
|
||||
$chunk = 1024;
|
||||
while ($size > 0) {
|
||||
fputs($fp, str_pad('', min($chunk,$size)));
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
Bug #45392 (ob_start()/ob_end_clean() and memory_limit)
|
||||
--INI--
|
||||
display_errors=stderr
|
||||
--XFAIL--
|
||||
The issue has not yet been resolved.
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (getenv("USE_ZEND_ALLOC") === "0") {
|
||||
@@ -10,7 +12,7 @@ if (getenv("USE_ZEND_ALLOC") === "0") {
|
||||
--FILE--
|
||||
<?php
|
||||
echo __LINE__ . "\n";
|
||||
ini_set('memory_limit', 100);
|
||||
ini_set('memory_limit', "2M");
|
||||
ob_start();
|
||||
$i = 0;
|
||||
while($i++ < 5000) {
|
||||
|
||||
Reference in new issue
Block a user