Memory problem Segmentation fault / exhaust 
Author Message
 Memory problem Segmentation fault / exhaust

Hey, and a happy newyear to everybody.

I have some weird problem that i can't fix, i'll try to explain as good as i
can.

I'm running a php on the command line to build over 1000 html pages but i'm
running out of memory after 20 pages when i really shouldn't. Each of these
pages contain several templates, categories and links. But when counted
together it shouldn't require over a 100kb. These categories & links of a
page are fetched inside a class.

An example that works almost instantly:
<?

$cron_query = mysql_query("SELECT page_id as id FROM db_page WHERE
page_status='1'");
while($cron_sql = mysql_fetch_assoc($cron_query)) {

  $page = new Page($cron_sql->id); // this will fetch some data like name,
it's template to use,.. small things like this.
  echo $page->name."\n";

Quote:
}

?>

BUT when fetching categorie's & links for this page:

<?

$cron_query = mysql_query("SELECT page_id as id FROM db_page WHERE
page_status='1'");
while($cron_sql = mysql_fetch_assoc($cron_query)) {

  $page = new Page($cron_sql->id); // this will fetch some data like name,
it's template to use,.. small things like this.
  $page->Contents();
  echo $page->name."\n";

Quote:
}

?>

this will fail after 20 pages.

the function Contents() contains this:

    $this->column    = array(); // page has 3 columns
    $this->column[1]->category = array(); // contains category along with
it's name and all of it's links.
    $this->column[1]->total = 0;
    $this->column[2]->category = array();
    $this->column[2]->total = 0;
    $this->column[3]->category = array();
    $this->column[3]->total = 0;
    $this->category  = array(); // contains every category by id with a
reference into the column->category array.
    $this->box       = array(); // same as above, but other kind of
category.
    $this->link      = array(); // contains every link of every category
with it's reference to column->category->link

It gets a little more complicated but i'll spare you from the rest since i
think it must be this structure that is causing my problem.

Also i noticed the following:

On top of my script i include my 'functions.php' script that contains stuff
like these classes. On top of that script it said 'session_start();' If i
then run my script from the command line it will buffer the output like
'echo $page->name."\n";' and end with a Segmentation fault when out of
memory. When session_start is off it will output one by one and end in:
<b>Fatal error</b>:  Allowed memory size of 8388608 bytes exhausted (tried
to allocate 46 bytes) in <b>/var/www/html/start_be/bin/build.php</b> on line
<b>118</b><br>

I've been debugging for days and days without getting any step closer...
please help

Running php 4.1.2 on Red Hat 7.1 with apache 1.3.27

--
Groetjes,

---

Projectleider Start.be
http://www.*-*-*.com/



Wed, 22 Jun 2005 00:55:55 GMT  
 Memory problem Segmentation fault / exhaust
I notice immediately that you are creating new Page objects but you are not
disposing of them.

Quote:

> Hey, and a happy newyear to everybody.

> I have some weird problem that i can't fix, i'll try to explain as good as
> i can.

> I'm running a php on the command line to build over 1000 html pages but
> i'm running out of memory after 20 pages when i really shouldn't. Each of
> these pages contain several templates, categories and links. But when
> counted together it shouldn't require over a 100kb. These categories &
> links of a page are fetched inside a class.

> An example that works almost instantly:
> <?

> $cron_query = mysql_query("SELECT page_id as id FROM db_page WHERE
> page_status='1'");
> while($cron_sql = mysql_fetch_assoc($cron_query)) {

>   $page = new Page($cron_sql->id); // this will fetch some data like name,
> it's template to use,.. small things like this.
>   echo $page->name."\n";
> }

> ?>

> BUT when fetching categorie's & links for this page:

> <?

> $cron_query = mysql_query("SELECT page_id as id FROM db_page WHERE
> page_status='1'");
> while($cron_sql = mysql_fetch_assoc($cron_query)) {

>   $page = new Page($cron_sql->id); // this will fetch some data like name,
> it's template to use,.. small things like this.
>   $page->Contents();
>   echo $page->name."\n";
> }

> ?>

> this will fail after 20 pages.

> the function Contents() contains this:

>     $this->column    = array(); // page has 3 columns
>     $this->column[1]->category = array(); // contains category along with
> it's name and all of it's links.
>     $this->column[1]->total = 0;
>     $this->column[2]->category = array();
>     $this->column[2]->total = 0;
>     $this->column[3]->category = array();
>     $this->column[3]->total = 0;
>     $this->category  = array(); // contains every category by id with a
> reference into the column->category array.
>     $this->box       = array(); // same as above, but other kind of
> category.
>     $this->link      = array(); // contains every link of every category
> with it's reference to column->category->link

> It gets a little more complicated but i'll spare you from the rest since i
> think it must be this structure that is causing my problem.

> Also i noticed the following:

> On top of my script i include my 'functions.php' script that contains
> stuff like these classes. On top of that script it said 'session_start();'
> If i then run my script from the command line it will buffer the output
> like 'echo $page->name."\n";' and end with a Segmentation fault when out
> of memory. When session_start is off it will output one by one and end in:
> <b>Fatal error</b>:  Allowed memory size of 8388608 bytes exhausted (tried
> to allocate 46 bytes) in <b>/var/www/html/start_be/bin/build.php</b> on
> line <b>118</b><br>

> I've been debugging for days and days without getting any step closer...
> please help

> Running php 4.1.2 on Red Hat 7.1 with apache 1.3.27

> --
> Groetjes,

> ---

> Projectleider Start.be
> http://start.be

--
----------------------------------
Fast automatic Paradox table repair at a click of a mouse!
http://www.sundialservices.com/products/chimneysweep


Wed, 22 Jun 2005 02:17:44 GMT  
 Memory problem Segmentation fault / exhaust
Oh yeah sorry...  was a bit hasty writing this sample code...

I've tried about everything, unsetting $page before opening the new one,
unsetting at the end of the loop, i've even unset every property of this
object but it stays the same.

--
Groetjes,

---

Projectleider Start.be
http://start.be

Quote:
> I notice immediately that you are creating new Page objects but you are
not
> disposing of them.


> > Hey, and a happy newyear to everybody.

> > I have some weird problem that i can't fix, i'll try to explain as good
as
> > i can.

> > I'm running a php on the command line to build over 1000 html pages but
> > i'm running out of memory after 20 pages when i really shouldn't. Each
of
> > these pages contain several templates, categories and links. But when
> > counted together it shouldn't require over a 100kb. These categories &
> > links of a page are fetched inside a class.

> > An example that works almost instantly:
> > <?

> > $cron_query = mysql_query("SELECT page_id as id FROM db_page WHERE
> > page_status='1'");
> > while($cron_sql = mysql_fetch_assoc($cron_query)) {

> >   $page = new Page($cron_sql->id); // this will fetch some data like
name,
> > it's template to use,.. small things like this.
> >   echo $page->name."\n";
> > }

> > ?>

> > BUT when fetching categorie's & links for this page:

> > <?

> > $cron_query = mysql_query("SELECT page_id as id FROM db_page WHERE
> > page_status='1'");
> > while($cron_sql = mysql_fetch_assoc($cron_query)) {

> >   $page = new Page($cron_sql->id); // this will fetch some data like
name,
> > it's template to use,.. small things like this.
> >   $page->Contents();
> >   echo $page->name."\n";
> > }

> > ?>

> > this will fail after 20 pages.

> > the function Contents() contains this:

> >     $this->column    = array(); // page has 3 columns
> >     $this->column[1]->category = array(); // contains category along
with
> > it's name and all of it's links.
> >     $this->column[1]->total = 0;
> >     $this->column[2]->category = array();
> >     $this->column[2]->total = 0;
> >     $this->column[3]->category = array();
> >     $this->column[3]->total = 0;
> >     $this->category  = array(); // contains every category by id with a
> > reference into the column->category array.
> >     $this->box       = array(); // same as above, but other kind of
> > category.
> >     $this->link      = array(); // contains every link of every category
> > with it's reference to column->category->link

> > It gets a little more complicated but i'll spare you from the rest since
i
> > think it must be this structure that is causing my problem.

> > Also i noticed the following:

> > On top of my script i include my 'functions.php' script that contains
> > stuff like these classes. On top of that script it said
'session_start();'
> > If i then run my script from the command line it will buffer the output
> > like 'echo $page->name."\n";' and end with a Segmentation fault when out
> > of memory. When session_start is off it will output one by one and end
in:
> > <b>Fatal error</b>:  Allowed memory size of 8388608 bytes exhausted
(tried
> > to allocate 46 bytes) in <b>/var/www/html/start_be/bin/build.php</b> on
> > line <b>118</b><br>

> > I've been debugging for days and days without getting any step closer...
> > please help

> > Running php 4.1.2 on Red Hat 7.1 with apache 1.3.27

> > --
> > Groetjes,

> > ---

> > Projectleider Start.be
> > http://start.be

> --
> ----------------------------------
> Fast automatic Paradox table repair at a click of a mouse!
> http://www.sundialservices.com/products/chimneysweep



Wed, 22 Jun 2005 03:13:47 GMT  
 Memory problem Segmentation fault / exhaust
Could this have something to do with the memory settings in your php.ini
file?
memory_limit = 32M      ; Maximum amount of memory a script may consume
(8MB)  <--- I've upped mine here. :)

Good luck.


Quote:
> Hey, and a happy newyear to everybody.

> I have some weird problem that i can't fix, i'll try to explain as good as
i
> can.

> I'm running a php on the command line to build over 1000 html pages but
i'm
> running out of memory after 20 pages when i really shouldn't. Each of
these
> pages contain several templates, categories and links. But when counted
> together it shouldn't require over a 100kb. These categories & links of a
> page are fetched inside a class.

> An example that works almost instantly:
> <?

> $cron_query = mysql_query("SELECT page_id as id FROM db_page WHERE
> page_status='1'");
> while($cron_sql = mysql_fetch_assoc($cron_query)) {

>   $page = new Page($cron_sql->id); // this will fetch some data like name,
> it's template to use,.. small things like this.
>   echo $page->name."\n";
> }

> ?>

> BUT when fetching categorie's & links for this page:

> <?

> $cron_query = mysql_query("SELECT page_id as id FROM db_page WHERE
> page_status='1'");
> while($cron_sql = mysql_fetch_assoc($cron_query)) {

>   $page = new Page($cron_sql->id); // this will fetch some data like name,
> it's template to use,.. small things like this.
>   $page->Contents();
>   echo $page->name."\n";
> }

> ?>

> this will fail after 20 pages.

> the function Contents() contains this:

>     $this->column    = array(); // page has 3 columns
>     $this->column[1]->category = array(); // contains category along with
> it's name and all of it's links.
>     $this->column[1]->total = 0;
>     $this->column[2]->category = array();
>     $this->column[2]->total = 0;
>     $this->column[3]->category = array();
>     $this->column[3]->total = 0;
>     $this->category  = array(); // contains every category by id with a
> reference into the column->category array.
>     $this->box       = array(); // same as above, but other kind of
> category.
>     $this->link      = array(); // contains every link of every category
> with it's reference to column->category->link

> It gets a little more complicated but i'll spare you from the rest since i
> think it must be this structure that is causing my problem.

> Also i noticed the following:

> On top of my script i include my 'functions.php' script that contains
stuff
> like these classes. On top of that script it said 'session_start();' If i
> then run my script from the command line it will buffer the output like
> 'echo $page->name."\n";' and end with a Segmentation fault when out of
> memory. When session_start is off it will output one by one and end in:
> <b>Fatal error</b>:  Allowed memory size of 8388608 bytes exhausted (tried
> to allocate 46 bytes) in <b>/var/www/html/start_be/bin/build.php</b> on
line
> <b>118</b><br>

> I've been debugging for days and days without getting any step closer...
> please help

> Running php 4.1.2 on Red Hat 7.1 with apache 1.3.27

> --
> Groetjes,

> ---

> Projectleider Start.be
> http://start.be



Thu, 23 Jun 2005 08:32:36 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. memory usage.....segmentation fault

2. Another Segmentation Fault problem

3. Strange segmentation fault problem with C++ extension

4. how to find segmentation fault problem with Sun f90

5. segmentation fault problem

6. dimensions and segmentation fault problem

7. Problem with Tcl_Alloc, Tcl_LinkVar, and segmentation faults

8. Segmentation Fault problem

9. Memory fault problem

10. memory active causes memory fault

11. visual works 3.1 image has segmentation fault on 2.4 kernel (red hat 8.0)

12. segmentation fault on gabage collect

 

 
Powered by phpBB® Forum Software