CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • "Fatal error: Out of memory" during contacts export
Pages: [1]

Author Topic: "Fatal error: Out of memory" during contacts export  (Read 1955 times)

sypl

  • I post occasionally
  • **
  • Posts: 37
  • Karma: 1
"Fatal error: Out of memory" during contacts export
April 13, 2009, 09:33:53 am
I'm getting this error whenever I try to export even a small number of contacts (as few as 27) via an advanced search:

Code: [Select]
Fatal error: Out of memory (allocated 32505856) (tried to allocate 512 bytes) in /home/sites/mysite.org/public_html/sites/all/modules/civicrm/packages/DB/mysql.php on line 383
I've tried upping the memory limits to up to 128MB via my php5.ini file and .htacess. Looking in Drupal admin, the changes in the php5 file are reflected in the status report, but every time I run an export it throws the same error, a vast majority of the time at the same line (line 383 of mysql.php). Oddly enough, this line seems to be a blank in the file.

It may be worth noting that this export did work about a month ago, before I updated to 2.2.2. I'm not sure what's changed though.

I've run a copy locally and tried large exports, which work just fine even with as low as 32MB of memory, so I'm mystified why my queries are failing on the site. Any help that can be provided would be appreciated.

Using:
Drupal 6.10
CiviCRM 2.2.2
PHP 5.2.9
MySQL 5.0.67
« Last Edit: April 14, 2009, 04:10:38 am by sypl »

sypl

  • I post occasionally
  • **
  • Posts: 37
  • Karma: 1
Re: "Fatal error: Out of memory" during contacts export
April 14, 2009, 05:23:49 am
My apologies, it seems mysql.php line 383 is not blank. It's in the middle fo the following function (highlighted in red):

Quote
function fetchInto($result, &$arr, $fetchmode, $rownum = null)
    {
        if ($rownum !== null) {
            if (!@mysql_data_seek($result, $rownum)) {
                return null;
            }
        }
        if ($fetchmode & DB_FETCHMODE_ASSOC) {
            $arr = @mysql_fetch_array($result, MYSQL_ASSOC);
            if ($this->options['portability'] & DB_PORTABILITY_LOWERCASE && $arr) {
                $arr = array_change_key_case($arr, CASE_LOWER);
            }
        } else {
            $arr = @mysql_fetch_row($result);
        }
        if (!$arr) {
            return null;
        }
        if ($this->options['portability'] & DB_PORTABILITY_RTRIM) {
            /*
             * Even though this DBMS already trims output, we do this because
             * a field might have intentional whitespace at the end that
             * gets removed by DB_PORTABILITY_RTRIM under another driver.
             */
            $this->_rtrimArrayValues($arr);
        }
        if ($this->options['portability'] & DB_PORTABILITY_NULL_TO_EMPTY) {
            $this->_convertNullArrayValuesToEmpty($arr);
        }
        return DB_OK;
    }

I've compared and this section of code isn't any different from the previous version of CiviCRM I was using (2.1.4), which exported just fine. Somewhere along the way it seems a large memory leak is occurring, causing all but the smallest of queries to blow up. Other than the error message about the line above though I don't have much else to go on as that error is the only thing that appears on a clear white page when the export fails.

I'd be thankful for any help on this. Being unable to export any data is a pretty serious problem, to say the least.

UPDATE: It seems this problem only occurs with searches involving tags. If I run a search to export contacts from several groups there are no problems with it, even if the number of contacts is 800+. Run a search on tags though and seemingly an query with more than 80 results seems to throw the 'out of memory' error.
« Last Edit: April 14, 2009, 05:58:18 am by sypl »

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: "Fatal error: Out of memory" during contacts export
April 14, 2009, 07:03:47 am

1. what is your tag structure? r u using hierarchical tags

2. how big is your db

3. can u try to do the same search on demo and see if u can reproduce (i doubt it)

4. any chance we can get ssh access to your machine? if so contact us on IRC

thanx

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

sypl

  • I post occasionally
  • **
  • Posts: 37
  • Karma: 1
Re: "Fatal error: Out of memory" during contacts export
April 15, 2009, 05:09:24 am
Hi Donald, thanks for replying.

1. The tags aren't arranged in any hierarachal structure. It's just a plain list of tags. There are about 15 of them.

2. Database is just under 4MB

3. Couldn't reproduce it on the demo, but that's also not possible because the demo doesn't have enough data in it. Even selecting every tag it only returns about 40 results, a size which my current installation can also handle. It's only when there are over about 80 tagged results that the export goes wrong.

4. Yeah, I think so. I'll find you on the channel.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • "Fatal error: Out of memory" during contacts export

This forum was archived on 2017-11-26.