Ad Widget

Collapse

PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mdresden
    Junior Member
    • Jan 2014
    • 16

    #1

    PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate

    I am running zabbix 2.2 on a vm with 8 real cores, 12GB ram currently.

    I will be monitoring 3100 devices.

    Currently I have mysql also on this box but it will be migrated off soon.

    I have access to unlimited hardware resources, memory, etc, and will be scaling this up into a better distributed environment, but for now i am trying to get a proof of concept up at my company to switch to zabbix.

    The error I am working to resolve can be reproduces as follows:
    1. Login to zabbix frontend
    2. select Monitoring tab
    3. select latest data
    4. select any large group of servers


    From there it spins a long time and eventually I get a php error.

    the PHP error is usually some variation of:
    Code:
    PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 32 bytes) in /usr/share/zabbix/include/classes/api/CZBXAPI.php on line 323
    I have tried increasing the memory limit in php.ini and just making it unlimited.

    I have increase ValueCacheSize which I thought may be related (no additional amount here helped)

    Currently my server runs with about 2Gigs free of the 12 it has.

    Does anyone know more specifically what needs to be adjusted.

    Here in the php file snippet that complains:

    Code:
     316         protected function createRelationMap(array $objects, $baseField, $foreignField, $table = null) {
     317                 $relationMap = new CRelationMap();
     318
     319                 // create the map from a database table
     320                 if ($table) {
     321                         $res = DBselect(API::getApi()->createSelectQuery($table, array(
     322                                 'output' => array($baseField, $foreignField),
     323                                 'filter' => array($baseField => array_keys($objects)),
     324                                 'nodeids' => get_current_nodeid(true)
     325                         )));
     326                         while ($relation = DBfetch($res)) {
     327                                 $relationMap->addRelation($relation[$baseField], $relation[$foreignField]);
     328                         }
     329                 }
     330
     331                 // create a map from the base objects
     332                 else {
     333                         foreach ($objects as $object) {
     334                                 $relationMap->addRelation($object[$baseField], $object[$foreignField]);
     335                         }
     336                 }
     337
     338                 return $relationMap;
     339         }
    Here are the setting from my server conf file:

    Code:
    # cat /etc/zabbix/zabbix_server.conf | egrep '^[^#]'
    LogFile=/var/log/zabbix/zabbix_server.log
    LogFileSize=0
    PidFile=/var/run/zabbix/zabbix_server.pid
    DBHost=localhost
    DBName=zabbix
    DBUser=zabbix
    DBPassword=<BLAH>
    DBSocket=/var/lib/mysql/mysql.sock
    StartPollers=750
    StartPollersUnreachable=80
    StartTrappers=20
    StartPingers=10
    StartDiscoverers=250
    JavaGateway=zabbix.gale.web
    JavaGatewayPort=10052
    StartJavaPollers=5
    SNMPTrapperFile=/var/log/snmptt/snmptt.log
    CacheSize=1G
    StartDBSyncers=50
    HistoryCacheSize=1G
    TrendCacheSize=1G
    HistoryTextCacheSize=1G
    ValueCacheSize=1G
    AlertScriptsPath=/usr/lib/zabbix/alertscripts
    ExternalScripts=/usr/lib/zabbix/externalscripts
    Fping6Location=/usr/sbin/fping6

    Here are some screen shots of zabbix graphs
    Attached Files
  • pjelou
    Junior Member
    • Jan 2014
    • 8

    #2
    I had the same problem, editing memory_limit value in php.ini won't work, you have to edit in file /etc/zabbix/apache.conf
    php_value memory_limit
    2M.
    For me 512MB was sufficient.

    Comment

    • mdresden
      Junior Member
      • Jan 2014
      • 16

      #3
      Solved

      Thanks alot !!! It turns out as you said there are php settings that over ride the php.ini setting in the zabbix vhost conf file

      Comment

      • nelteren
        Junior Member
        • Sep 2008
        • 16

        #4
        cannot find apache.conf

        I installed zabbix on debian
        Currenty I also run zabbix 2.2
        Linux version 2.6.32-5-amd64 (Debian 2.6.32-48squeeze6) ([email protected]) (gcc version 4.3.5 (Debian 4.3.5-4) ) #1 SMP Tue May 13 16:34:35 UTC 2014
        MEM

        I also get the mem error but cannot find /etc/zabbix/apache.conf and not on an othter location

        So I changed :
        /etc/apache2/sites-enabled/000-default
        and added:

        <VirtualHost *:80>
        ServerAdmin webmaster@localhost

        DocumentRoot /var/www

        php_value memory_limit 1024M
        php_value post_max_size 128M


        <Directory />
        Options FollowSymLinks

        ====================

        It worked for me

        Comment

        Working...