By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,231 Members | 1,707 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,231 IT Pros & Developers. It's quick & easy.

Fatal Error: Allowed memory size of 8388608 bytes exhausted - HELP

P: n/a
Actually the client is saying it sometimes happens and sometimes
doesn't happen, and when they refresh their screen it clears itself (I
assume the memory clears).

Here is line 1135:
[PHP]$result = mysql_query($this->query, $this->dbcnx) or
die(@include("$DOCUMENT_ROOT${devpath}errors/query_error.php"));[/PHP]

It is found here in this class method:

class mySqlQuery {

var $query,$dbcnx; // $dbcnx is a mySqlConnection object
function mySqlQuery($query,$dbcnx) {
$this->query = $query;
$this->dbcnx = $dbcnx;
}

function runQuery() {
global $devpath,$DOCUMENT_ROOT; if
(preg_match('/development\//i', $devpath)) {
$result = mysql_query($this->query, $this->dbcnx) or
die(@include("$DOCUMENT_ROOT${devpath}errors/query_error.php?msg=" .
urlencode(mysql_error())));
} else {
$result = mysql_query($this->query, $this->dbcnx) or
die(@include("$DOCUMENT_ROOT${devpath}errors/query_error.php"));
}
return $result;
}
function getResult() {
$runquery = $this->runQuery();
$count = 0;
while ($row = mysql_fetch_object($runquery)) {
$result[$count] = $row;
$count++;
}
return $result;
}

function getRows($what = 'select') {
$runquery = $this->runQuery();
$count = 0;

if (strcmp(strtolower($what), 'affected') == 0) {
$row = @mysql_affected_rows($this->dbcnx);
} else {
$row = @mysql_num_rows($this->dbcnx);
}

if (!$row) {
return false;
}

return $row;
}

function freeResult() {
@mysql_free_result($this->runQuery());
}

}

Hans Zaunere wrote:

The following occurs when we query records on the 'interns' table:

Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to
allocate 40 bytes) in ../intern.inc on line 1135
Show me line 1135 and a couple lines surrounding it - I bet this isn't
a
MySQL error.

See http://us3.php.net/ini_set and search the page for memory_limit -
notice it's 8M by default. Thus, it's probably a PHP error and sloppy
code.

H
Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a

"Phil Powell" <so*****@erols.com> schreef in bericht
news:1c**************************@posting.google.c om...
Actually the client is saying it sometimes happens and sometimes
doesn't happen, and when they refresh their screen it clears itself (I
assume the memory clears).

Here is line 1135:
[PHP]$result = mysql_query($this->query, $this->dbcnx) or
die(@include("$DOCUMENT_ROOT${devpath}errors/query_error.php"));[/PHP]

It is found here in this class method:

class mySqlQuery {

var $query,$dbcnx; // $dbcnx is a mySqlConnection object
function mySqlQuery($query,$dbcnx) {
$this->query = $query;
$this->dbcnx = $dbcnx;
}

function runQuery() {
global $devpath,$DOCUMENT_ROOT; if
(preg_match('/development\//i', $devpath)) {
$result = mysql_query($this->query, $this->dbcnx) or
die(@include("$DOCUMENT_ROOT${devpath}errors/query_error.php?msg=" .
urlencode(mysql_error())));
} else {
$result = mysql_query($this->query, $this->dbcnx) or
die(@include("$DOCUMENT_ROOT${devpath}errors/query_error.php"));
}
return $result;
}
function getResult() {
$runquery = $this->runQuery();
$count = 0;
while ($row = mysql_fetch_object($runquery)) {
$result[$count] = $row;
$count++;
}
return $result;
}

function getRows($what = 'select') {
$runquery = $this->runQuery();
$count = 0;

if (strcmp(strtolower($what), 'affected') == 0) {
$row = @mysql_affected_rows($this->dbcnx);
} else {
$row = @mysql_num_rows($this->dbcnx);
}

if (!$row) {
return false;
}

return $row;
}

function freeResult() {
@mysql_free_result($this->runQuery());
}

}

Hans Zaunere wrote:

The following occurs when we query records on the 'interns' table:

Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to
allocate 40 bytes) in ../intern.inc on line 1135
Show me line 1135 and a couple lines surrounding it - I bet this isn't
a
MySQL error.

See http://us3.php.net/ini_set and search the page for memory_limit -
notice it's 8M by default. Thus, it's probably a PHP error and sloppy
code.

H


What is the size of the data you're trying to query from mysql???
Jul 17 '05 #2

P: n/a
so*****@erols.com (Phil Powell) wrote in message news:<1c**************************@posting.google. com>...
Actually the client is saying it sometimes happens and sometimes
doesn't happen, and when they refresh their screen it clears itself (I
assume the memory clears).

Here is line 1135:
[PHP]$result = mysql_query($this->query, $this->dbcnx) or
die(@include("$DOCUMENT_ROOT${devpath}errors/query_error.php"));[/PHP]


As was discussed here a few weeks ago, garbage collection is grossly
inefficient in objects in PHP 4. In fact, object memory collection is
so bad it is basically broken. I found this out when I did something
like what you've done here, and moved a function into a class so that
it became a class method. Immediately I began to have max memory
problems.

By default, there is an 8 meg limit on any PHP script. Outside of
objects, PHP is a miracle of efficiency with this 8 megs, and uses
pointers that point to resources that are outside of PHP. Inside of
objects, problems begin.

If the server is your own, you change the default 8 megs to something
higher.
Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.