- Status changed to Postponed: needs info
about 2 months ago 12:28pm 10 July 2024 - 🇺🇸United States cilefen
Welcome to the Drupal Community. What you see there isn't normal. When PHP runs out of memory it can be difficult to interpret the error line because that is just the point at which PHP completely ran out of memory. The cause is sometimes elsewhere.
But reports like this require steps to reproduce. Because this bug report is missing those I am postponing the issue on more information.
I also don't understand what's going on. After I updated from version 7.94 to version 7.101, the php-fpm log reported the same. At first I thought it was because the memory_limit parameter was not enough, so I changed it from 1024MB -> 3GB but that message still PHP Fatal error appeared, and I continued to change from 3GB->4GB but the message still appeared in the log.
- 🇺🇸United States cilefen
Probably no amount of allocated memory will be enough as there is likely a code issue here. But you have not added steps to reproduce to this issue. For example, we don't even know on which page, or even on which kind of page, your error occurs. We don't know which modules are installed, and so on.
Because I don't know which module is causing the error, I'm temporarily fixing it in the following way
in includes/cache.incfunction getMultiple(&$cids) { try { // Garbage collection necessary when enforcing a minimum cache lifetime. $this->garbageCollection($this->bin); $cache = array(); $batchSize = 1000; // Adjust the size of each batch foreach (array_chunk($cids, $batchSize) as $chunk) { $result = db_query('SELECT cid, data, created, expire, serialized FROM {' . db_escape_table($this->bin) . '} WHERE cid IN (:cids)', array(':cids' => $chunk)); foreach ($result as $item) { $item = $this->prepareItem($item); if ($item) { $cache[$item->cid] = $item; } } } // Update the $cids array to only include those that were not found. $cids = array_diff($cids, array_keys($cache)); return $cache; } catch (Exception $e) { // If the database is never going to be available, cache requests should // return FALSE in order to allow exception handling to occur. return array(); } } ///// protected function prepareItem($cache) { global $user; if (!isset($cache->data)) { return FALSE; } if ($cache->expire != CACHE_PERMANENT && variable_get('cache_lifetime', 0) && isset($_SESSION['cache_expiration'][$this->bin]) && $_SESSION['cache_expiration'][$this->bin] > $cache->created) { return FALSE; } if ($cache->serialized) { $memory_limit = ini_get('memory_limit'); $memory_usage = memory_get_usage(); // Chuyển đổi giá trị $memory_limit sang byte $memory_limit_bytes = $this->convertToBytes($memory_limit); if ($memory_usage + strlen($cache->data) > $memory_limit_bytes * 0.9) { // Limit 90% memory return FALSE; } $cache->data = unserialize($cache->data); } return $cache; } private function convertToBytes($value) { $unit = strtolower(substr($value, -1)); $bytes = (int) $value; switch($unit) { case 'g': $bytes *= 1024 * 1024 * 1024; break; case 'm': $bytes *= 1024 * 1024; break; case 'k': $bytes *= 1024; break; } return $bytes; }