Elxis CMS Forum

Support => Database => Topic started by: muharihar on March 11, 2009, 05:03:04

Title: Need Help: Oracle-Fatal error: Allowed memory size of 8388608 bytes exhausted
Post by: muharihar on March 11, 2009, 05:03:04
hi guys...

i need help to fix this problem:

Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 41 bytes) in /opt/lampp/htdocs/sakwebelx/websakelx/includes/Core/database.php on line 335.


the line 335 is:

protected function _cursorReplacer() {
      $compatDrivers = array ('oci8', 'oci805', 'oci8po', 'oracle');
      if (in_array($this->_resource->databaseType, $compatDrivers)) {
         $newfields = array();
         if (isset($this->_cursor->fields) && is_array($this->_cursor->fields) && (count($this->_cursor->fields) > 0)) {
            foreach ($this->_cursor->fields as $key => $val) {
               $low = preg_replace('/^('.$this->compatPrefix.')/', '', strtolower($key));
               $newfields[$low] = $val;
            }
            $this->_cursor->fields = $newfields;
         }

         if (isset($this->_cursor->_array) && is_array($this->_cursor->_array) && (count($this->_cursor->_array) > 0)) {
            $newarray = array();
            foreach ($this->_cursor->_array as $k => $a) {
               if (is_array($a) && (count($a) > 0)) {
                  foreach ($a as $key => $val) {
                     $low = preg_replace('/^('.$this->compatPrefix.')/', '', strtolower($key));
                     $newarray[$k][$low] = $val; --> LINE 335
                  }
               }
            }
            $this->_cursor->_array = $newarray;
         }
      }
   }


Note:
1. Elxis With Oracle as the database
2. Linux (Red had) as the OS
Title: Re: Need Help: Oracle-Fatal error: Allowed memory size of 8388608 bytes exhausted
Post by: datahell on March 11, 2009, 10:48:13
This is where Elxis applies the compatibility prefix (qq) for Oracle. This happens because Oracle has some column names as reserved. For instance "access". The compatibility prefix will be added to reserved names, so "access" will become "qqaccess" for Oracle. I need to see the query to understand why the replacement procedure halts. Can you enable debug and copy-paste here the query with the problem?
Title: Re: Need Help: Oracle-Fatal error: Allowed memory size of 8388608 bytes exhausted
Post by: muharihar on March 17, 2009, 03:49:36
the query is (not elxis database, i make a nother db connection to access this query):

SELECT   SUBSTR (a.kd_jenis_nilai, 0, sys_str_pos (a.kd_jenis_nilai, '|') - 1) kode,
         SUBSTR (a.kd_jenis_nilai, sys_str_pos (a.kd_jenis_nilai, '|') + 1, 100) kode_1,
         a.label_nilai label,
         SUBSTR (a.label_nilai, sys_str_pos (a.label_nilai, '|') + 1, 100) label_1,
         a.nilai_1 jumlah, TO_CHAR (tgl_generate, 'DD-MM-YYYY HH24:MI') tgl,
         DECODE ('PROP',
                 'PROP', kd_lokasi_2,
                 'KAB', kd_lokasi_3,
                 'KEC', kd_lokasi_4,
                 'DES', kd_lokasi_5,
                 kd_lokasi_6
                ) kode_induk
    FROM wh_tm_lap a
   WHERE kd_jenis_lokasi = 'PROP'
     AND kd_lap = '104002'
     AND kd_lokasi_1 = '34'
     AND kd_lokasi_2 = '04'
     AND kd_tipe_lap = '102'
     AND kd_waktu_1 = '2009'
     AND kd_waktu_2 = '03'
     AND tgl_generate =
            (SELECT MAX (tgl_generate)
               FROM wh_tm_lap a
              WHERE kd_jenis_lokasi = 'PROP'
                AND kd_lap = '104002'
                AND kd_lokasi_1 = '34'
                AND kd_lokasi_2 = '04'
                AND kd_tipe_lap = '102'
                AND kd_waktu_1 = '2009'
                AND kd_waktu_2 = '03')
ORDER BY a.kd_lokasi_1, a.kd_lokasi_2, kd_lokasi_3, kd_lokasi_4, kd_lokasi_5, kode, kode_1;

but, after i increased the php memory_limit to 12M. the problem is solved.
i don't know why (the error) it's happen, maybe caused by memory leak?

thanks...
Title: Re: Need Help: Oracle-Fatal error: Allowed memory size of 8388608 bytes exhausted
Post by: datahell on March 17, 2009, 08:46:13
I guess this is because of the DECODE and SUBSTR functions, they consume some more memory...
Increase php's memory to 32mb or even 64mb, today servers have plenty of memory. The 8mb limit is a standard of the previous decade...