Fatal error: Allowed memory size...

13 posts by 3 authors in: Forums > CMS Builder
Last Post: June 7, 2010   (RSS)

By eduran582 - May 14, 2010 - edited: May 14, 2010

When attempting to load a table (with over 12k records), I get the following error message:

"Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 35 bytes) in /home/content/a/c/s/acsocitations/html/cmsAdmin/lib/viewer_functions.php on line 398"

I searched the forum and saw a couple of the same issue but they were all with older versions that seemed to update code that prevented this from happing (I currently have the latest: v2.04 running).

The page I'm trying to load is a simple 'search' page with only 37 total lines of code. The php code at the top (before the html) is as follows:

<?php header('Content-type: text/html; charset=utf-8');
require_once "/home/content/a/c/s/acsocitations/html/cmsAdmin/lib/viewer_functions.php";
list($citationsRecords, $citationsMetaData) = getRecords(array(
'tableName' => 'citations',
'loadUploads' => '0',
));
date_default_timezone_set ("America/Los_Angeles");
?>


The (main) html code is as follows:
<body>
<div align="center">
<font face="Tahoma" color="#8B0000" size="5">Search for Citation</font><br/><br/>
<form method="POST" action="citationsListViewer.php">
<input type="text" name="title,last_name,vehicle_license_or_vin_keyword" value="" style="text-transform: uppercase">
<input type="submit" name="submit" value="Search"><br/>
</form><br/>
<font color="#800000"><b>Total Records: <?php echo number_format($citationsMetaData['totalRecords'],0,'.',','); ?></b></font><br/><br/>
<font size="2">Today is: <b><?php echo date("M j, Y"); ?></b></font><br/>
</div>
</body>


When ALL the records are listed, this error does not come up. Anyone have an idea of what I can do?

Thanks!
Eric

NOTE: the php code has been edited from original post as after upgrading to v2.04, I noticed it said v1.35! I have since went back to v2.03. I'll be submitting another post on that.

Re: [eduran582] Fatal error: Allowed memory size...

By Jason - May 14, 2010

Hi,

Could you provide a link to where you're having the trouble so I can take a look?

Thanks.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Fatal error: Allowed memory size...

By eduran582 - May 14, 2010

Thanks for answering, Jason. Can I have your email address so I can send the information?

Re: [eduran582] Fatal error: Allowed memory size...

By Jason - May 14, 2010

jason@interactivetools.com
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [eduran582] Fatal error: Allowed memory size...

By Jason - May 17, 2010

Hi,

I located our problem.

The function getRecords has an option called 'loadCreatedBy'. This loads a record from the User Accounts table for each record returned. By default, this is set to on. Since we're loading so many records, I changed the option to off:

'loadCreatedBy' =>false,

This seems to have taken care of the problem.

Let me know if you run into any more issues.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Fatal error: Allowed memory size...

By eduran582 - May 19, 2010

Thanks, Jason. That did the trick! A good option to know when working with a bunch of records!

Re: [Jason] Fatal error: Allowed memory size...

By mark99 - May 19, 2010

What sort of things is that function needed for? I mean, is it something many of us could disable to improve performance (assuming some of our pages might not need it)?

Re: [mark99] Fatal error: Allowed memory size...

By Jason - May 19, 2010

Hi Mark,

This just pulls in information from the user account table for the person who created an individual record. You could always turn it off for pages that don't require this information.

You may not really see any change in performance since the number of records most pages return is fairly small. The only reason it was an issue in this case is that the page was returning well over 12,000 records.

Hope this helps.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Fatal error: Allowed memory size...

By mark99 - May 20, 2010 - edited: May 20, 2010

I don't need it so would still like to remove it on my output pages (I always think it's a good idea to disable anything you don't absolutely need hehe).

Do I assume that to do this you'd just add the line like so..

<?php

require_once "lib/viewer_functions.php";

list($isp_listRecords, $isp_listMetaData) = getRecords(array(
'tableName' => 'isp_list',
'perPage' => '3',
'loadCreatedBy' => 'false',
));
?>


Or must it be 'loadCreatedBy' => false, without the ' character?