logo
Ask your Symfony questions! Pay money and get answers fast! (more info)

Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

If the asker does not get an answer then they have 10 days to request a refund.

$25
MemCache errors with Symfony

Has anyone used MemCache with Symfony?

I run a simple query:

$c = new Criteria();
$c->add(GreenwichPeer::TEXTID, $id);
$c->add(GreenwichPeer::STATE, 'W');
$v = GreenwichPeer::doSelectOne($c, $con);


and I get a MemCache error:

Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 4 bytes) in /home/lib/MEMCACHELocalCache.class.php on line 85



Our MemCache class is a simple wrapper around the MemCache class you can find on php.net.

  public function Set( $key, $var, $expires=0 )
{

if( $expires < 0 ) return;
if( ! $expires ) $expires = $this->ttl;

//$exptime = time() + ($expires * 60 );
$exptime = ($expires * 60 );

// Set the cache
$key = SF_PRODUCT.'_'.strtoupper($key);

if( ! $this->cache->set( $key, $var, false, $exptime ) )
GeneralLogger::Write('LOCALMEMORYCACHE','Unable to set memcache key/value');

}

public function Get( $key )
{
$key = SF_PRODUCT.'_'.strtoupper($key);
return ( $this->cache->get( $key ) );
}



Anyone else have a problem like this?

I also tried the query like this:

$criteria0 = new Criteria();
$criteria0->add(CaoContentPeer::TEXTID, $id);
$criteria1 = $c->newCriterian(CaoContentPeer::STATE, 'W');
$criteria0->addAnd($criteria1);
$v = CaoContentPeer::doSelectOne($criteria0, $con);




Same problem.

This question has been answered.

marshall | 04/28/10 at 4:15pm Edit


(10) Responses

See a threaded view of answers?

Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

  • avatar
    Last edited:
    04/29/10
    5:32pm
    casivaagustin says:

    open your php.ini

    look for
    memory_limit = 8M

    change this to

    memory_limit = 16M

    You'll find that a few things are memory intensive, rather than processor intensive. Increasing the limit and restart apache will fix this.

    Note: You need to restart Apache after making any changes to php.ini.

  • avatar
    Last edited:
    04/28/10
    4:25pm
    Eduardo Raffoul says:

    Usually this kind of errors are related to your server configuration. You should look for php.ini (the path depends on your sever installation, if you're using lamp, xampp, mamp, etc..)

    Inside php.ini look for:
    memory_limit = ...

    change the value for:
    memory_limit = 32M

    and that should solve your problem

    PS1: You usually need root grant access to change this.
    PS2: You must restart your server for the new configuration to take effect

  • avatar
    Last edited:
    04/29/10
    5:32pm
    Arturo Linares says:

    If you still have memory problems and you are using php 5.1 there is a bug where recursive references leaks memory:

    http://bugs.php.net/bug.php?id=33595

    It was fixed in PHP 5.3

  • avatar
    Last edited:
    04/28/10
    5:30pm
    Bill Hunt says:

    The other posters are right, this doesn't have anything to do with Memcache; that runs outside of PHP. However, I would advise caution before increasing your memory limit willy-nilly; you probably should be debugging your query to find out why it's exceeding 8MB on a selectOne(), as you don't want to choke the server.

  • avatar
    Last edited:
    04/28/10
    8:06pm
    Martin Palacio says:

    What is exactly the line #85?

    How many records do you have in Greenwich table? Did you set the correct indexes?

    Try to deactivate MemCache. How long takes the query (SQL) to execute?

  • avatar
    Last edited:
    05/06/10
    2:17pm
    Ender Technology says:

    It initially appears that the database row contains almost 32MB of data. However, we need more information regarding your setup such as how the caching layer is integrated.

    Do you use the sfPropelMemcachePlugin? My other guess is that somewhere in that caching layer is attempting to retrieve/stuff almost 32MB of data.

    While investigating I recommend following "mppfiles" suggestion from above to reduce the number of variables in this situation.

    Rob O.
    Ender Tech Corp.
    www.endertech.com

    Previous versions of this answer: 05/06/10 at 2:17pm

  • avatar
    Last edited:
    04/29/10
    12:35pm
    Aleksander Wons says:

    I have faced similar problem when i passed sfContext object around the app.
    If You will try to serialize or unserialize sfContext object You will almost always runt into such problem.

    Additionally there is not enough background to figure out why this is happening. Symfony should not use more then 16MB per instance unless You are something that consumes Your memory.

    It is difficult to help when we have insufficient details.

  • avatar
    Last edited:
    04/28/10
    4:22pm
    casivaagustin says:

    open php.ini

    look for
    memory_limit = 8M

    change this to

    memory_limit = 16M

    16 or More if is needed

    You'll find that a few things are memory intensive, rather than processor intensive. Increasing the limit and restart apache will fix this.

    Note: You need to restart Apache after making any changes to php.ini.

  • avatar
    Last edited:
    04/28/10
    4:27pm
    casivaagustin says:

    open your php.ini

    look for
    memory_limit = 8M

    change this to

    memory_limit = 16M

    16 or More if yo Needed.

    You'll find that a few things are memory intensive, rather than processor intensive. Increasing the limit and restart apache will fix this.

    Note: You need to restart Apache after making any changes to php.ini.

  • avatar
    Last edited:
    04/29/10
    5:30pm
    marshall says:

    Thanks. This was a big part of it.

This question has expired.





Current status of this question: Completed



Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

If the asker does not get an answer then they have 10 days to request a refund.