[TYPO3-dev] How to handle many pages?

Martin Bless m.bless at gmx.de
Sat Jan 21 11:52:00 CET 2012


[Steffen Gebert] wrote:

>> I AM NOT happy because TYPO3 runs out of memory (> 128 MB) whenever
>> frontend rendering tries to determine which pages belong to a subtree:
>> 
>>    $csvstr = $this->pi_getPidList(...);
>> 
>
>could this be related to this one?
>http://forge.typo3.org/issues/32756

Yes, maybe. Although it's PHP 5.2.17 (and TYPO3 4.5.10).

Mentioning the $this->pi_getPidList(...); function was mainly a way to
ask this question in precise a way that people can understand the
problem immediately. And of course it holds true: it's running out of
memory.

This function works:

  function calculate() {
    $query = '
      SELECT
        uid,
        pid,
        hidden,
        tx_pagehits_hits - tx_hsopagehits_hits07 AS klicks,
        tx_hsopagehits_pagetype                  AS pagetype,
        SYS_LASTCHANGED                          AS SYS_LASTCHANGED,
        RAND()                                   AS random
      FROM
        pages
      WHERE
        deleted=0
    ';
    $res = $GLOBALS['TYPO3_DB']->sql_query($query);

    /*
    * Creating this structure for each page in $this->pages
    * 
    * 		$dataRow = array('uid'=>73, 'pid'=>1, ...);
    * 		$children = array( 512, 83, 99, 13);
    * 		$this->pages[$uid] = array();
    * 		$this->pages[$uid][0] = $dataRow;
    * 		$this->pages[$uid][1] = $children;
    */

    $this->pages = array();
    while ($row=$GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
      $uid = $row['uid'];
      $pid = $row['pid'];
      if (array_key_exists($uid, $this->pages)) {
        $this->pages[$uid][0] = $row;
      } else {
        $this->pages[$uid] = array($row, array());
      }
      if (array_key_exists($pid, $this->pages)) {
        $this->pages[$pid][1][] = $uid;
      } else {
        $this->pages[$pid] = array(array(), array($uid));
      }
    }
    $GLOBALS['TYPO3_DB']->sql_free_result($res);
    $children =
$this->getChildrenRecursive($this->params['startpage']);
    $entry = $this->getTopRows($children, $this->params['maxrows']);
    return $entry;
  }

BUT it will run out of memory if I select page.title AS WELL.


Let me put it this way: Since I have to confess that I'm far away from
being a PHP guru the question for me is:

Q: How do I test and analyze memory consumption of PHP objects and
arrays?

Q: How do monitor PHP garbage collection?


Martin

-- 
http://mbless.de




More information about the TYPO3-dev mailing list