Account created on 10 July 2024, 9 days ago
#

Recent comments

Because I don't know which module is causing the error, I'm temporarily fixing it in the following way
in includes/cache.inc

function 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;
}

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.

I tried adjusting the memory_limit parameter in php.ini to 7GB and received the following error message

PHP Fatal error:  Allowed memory size of 7516192768 bytes exhausted (tried to allocate 32768 bytes) in /home/.....com/public_html/..../includes/cache.inc on line 361
PHP Fatal error:  Allowed memory size of 7516192768 bytes exhausted (tried to allocate 20480 bytes) in /home/.....com/public_html/..../includes/cache.inc on line 449
PHP Fatal error:  Allowed memory size of 7516192768 bytes exhausted (tried to allocate 20480 bytes) in /home/.....com/public_html/..../includes/cache.inc on line 449
PHP Fatal error:  Allowed memory size of 7516192768 bytes exhausted (tried to allocate 20480 bytes) in /home/.....com/public_html/..../includes/cache.inc on line 449
PHP Fatal error:  Allowed memory size of 7516192768 bytes exhausted (tried to allocate 20480 bytes) in /home/.....com/public_html/..../includes/cache.inc on line 449
PHP Fatal error:  Allowed memory size of 7516192768 bytes exhausted (tried to allocate 262144 bytes) in /home/.....com/public_html/..../includes/database/database.inc on line 731

Production build 0.69.0 2024