[php-src] Issue #8334: "Out of memory" fatal error

From: Date: Sat, 09 Apr 2022 19:40:38 +0000
Subject: [php-src] Issue #8334: "Out of memory" fatal error
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-240823@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/8334 Author: jwwq ### Description when Apache process has big size (memory was allocated earlier), a fresh new script can't allocate relatively small chunk of memory and gives "Fatal error: Out of memory". This bug description is based on earlier bug #81585 "cached_chunks are not counted to real_size on shutdown" (https://bugs.php.net/bug.php?id=81585). That bug was fixed (thanks cmb@php.net), but when I checked the test script without memory limit, it fails. Looks like it's a different problem. The script to reproduce the problem is the same as in #81585 (https://pastebin.com/qh8hneTg), but you should set memory_limit to "-1". Please run it several times (6-7), and you'll get fatal error: ``` apache size: 1602 mb, memory usage/real usage: 0/1584 mb (0 items in array, 0 mb stored) apache overloaded (1602 mb), trying to alloc 200 mb Fatal error: Out of memory (allocated 1660944384) (tried to allocate 209715224 bytes) in bug_test.php on line 57 before crash: apache size: 1602 mb, memory usage/real usage: 0/1584 mb (0 items in array, 0 mb stored) ``` _(Please see #81585 bug description to get more information if needed)_ I think it's a bug because it's a new run of script, no memory is occupied by previous runs or another scripts, and PHP definitely can allocate 200 mb on totally free memory. (I don't know exactly how PHP allocation algorithm works, I know only that it can left memory allocated to reuse it faster (so Apache process stays big even there are no active scripts), and test script gets memory for many small strings, and maybe PHP doesn't free something when script ends. It's just a guess) _(system: Windows, Apache 2.4, php x32)_ ### PHP Version 8.1.4 ### Operating System Windows

« previous php.bugs (#240823) next »