• Resolved spinfly

    (@spinfly)


    New thread, as requested. ??

    On a WP site I am developing (PHP 5.3.20 with 128 MB of memory, WordPress 3.9.1, PHP Browser Detection 3.0), I see the following message:

    Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 71 bytes) in /…/wp-content/plugins/php-browser-detection/lib/Browscap.php on line 864

    When I delete the PHP Browser Detection plugin entirely and then reinstall and activate it, everything is fine. At least for a little while. Then, after a few days, the memory errors come back and the site dies.

    It looks like the memory errors seem to crop up in the section of code where the local browscap.ini file is parsed. I notice that the browscap.ini file that comes with the plugin (Version=5027, Released=Thu, 24 Apr 2014 07:41:24 +0000) is 10.4 MB, while a newer one that appeared on my server (Version=5029, Released=Thu, 08 May 2014 07:17:44 +0000) is 13.7 MB. Is it possible that PHP is choking when it tries to explode() and parse files that big? Perhaps it’s too much for PHP with 128 MB of memory to handle?

    Or is there something else that’s being cached and growing over time that I am not seeing?

    https://www.ads-software.com/plugins/php-browser-detection/

Viewing 15 replies - 1 through 15 (of 15 total)
  • I periodically get the same error messages as spinfly:

    [09-Jul-2014 14:38:01 UTC] PHP Warning: stream_socket_client(): unable to connect to https://browscap.org/version (Unable to find the socket transport "http" - did you forget to enable it when you configured PHP?) in /content/sites2/p/u/pushingouttheboat.co.uk/web/wp-content/plugins/php-browser-detection/lib/Browscap.php on line 1026
    [09-Jul-2014 14:38:02 UTC] PHP Warning: stream_socket_client(): unable to connect to https://browscap.org/stream?q=Full_PHP_BrowsCapINI (Unable to find the socket transport "http" - did you forget to enable it when you configured PHP?) in /content/sites2/p/u/pushingouttheboat.co.uk/web/wp-content/plugins/php-browser-detection/lib/Browscap.php on line 1026
    [09-Jul-2014 14:38:10 UTC] PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 197 bytes) in /content/sites2/p/u/pushingouttheboat.co.uk/web/wp-content/plugins/php-browser-detection/lib/Browscap.php on line 712

    Using versions: WordPress v3.9.1, PHP 5.4, PHP Browser Detection 3.0
    Would be grateful for a fix.

    I have the same problem. Deleting the plugin and reinstalling fixes the problem for a few days. Would greatly appreciate a fix.

    One thing to keep in mind…just because PHP has a certain amount of memory, doesn’t mean WordPress can use it all. It’s set to only use 40MB of memory by default. (You can check your WP memory with a plugin like Send System Info.) You can increase this in your wp-config.php file by adding this line:

    define( 'WP_MEMORY_LIMIT', '64M' );

    I’d recommend at least using 64MB for WP but on some sites I raise that to 96M (where I have 256MB PHP memory) and it really speeds things up.

    I don’t use the plugin you guys are having the issue with so I can’t confirm it will fix your issue, but it’s a good practice IMO and helps solve a lot of WP performance issues.

    Hope that helps!

    Thread Starter spinfly

    (@spinfly)

    Good idea, but in my case, I was already at 128M and still getting the errors.

    Plugin Author Mindshare Labs, Inc.

    (@mindshare)

    The issue is that the initial parse of the browscap file is pretty resource intensive because it a HUGE array. The error you got in megabytes is : 134.2 MB

    So you’ll need more memory.

    Thread Starter spinfly

    (@spinfly)

    But why is this NOT an issue when the plugin is first installed? And why does it suddenly become an issue after a few days or weeks? And why would deleting and reinstalling the plugin fix it?

    It’s not files themselves, as they don’t change from the point when the plugin is installed to the point that it fails. And I don’t think it’s the initial parse, because things indeed work fine when it is initially installed. Things only fail after a few days or weeks pass.

    I would guess that an increasing amount of information is stored to the DB until such a point that it’s too much for PHP to handle. And that deleting the plugin deletes the content from the DB and reinstalling the plugin allows it to start clean.

    In any case, if this is indeed a memory requirement of the plugin, is there any way to reduce it? Many shared hosting services have limited amount of memory:

    MediaTemple GS: 99MB limit
    BlueHost: 128MB limit
    HostGator: 256MB limit (nice!)
    DreamHost: 90M default
    GoDaddy: 64MB default
    RackSpace: 128MB default

    Plugin Author Mindshare Labs, Inc.

    (@mindshare)

    If it only happens after a few weeks it must be due to the automatic update check for a newer browscap file. We’ll look into it and see of we can find a solution for a future release.

    Plugin Author Mindshare Labs, Inc.

    (@mindshare)

    @spinfly – I just pushed a new dev version:

    https://downloads.www.ads-software.com/plugin/php-browser-detection.zip

    Can you test that and let me know if it fixes your memory issue?

    Thread Starter spinfly

    (@spinfly)

    The initial install went fine, but I will have to wait a week or two before I know if there’s still an issue.

    Is there any way to force the issue?

    Thread Starter spinfly

    (@spinfly)

    On three different dev sites, after two weeks, everything seems fine. No more errors.

    Can we push this fix out with the next release? ??

    Thanks!

    Plugin Author Mindshare Labs, Inc.

    (@mindshare)

    Cool! I will push it now.

    Thread Starter spinfly

    (@spinfly)

    Whoops, this problem reared its ugly head again on one of our production sites…

    Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 72 bytes) in …/wp-content/plugins/php-browser-detection/lib/Browscap.php on line 573

    PHP 5.4.31
    WP 3.9.2
    PHP Browser Detection 3.1.1
    128 MB of memory on the server

    I have a theory that site traffic might cause this issue to flare up. The site on which this error occurred has had 654 sessions and 4165 pageviews since the it launched about two weeks ago.

    Plugin Author Mindshare Labs, Inc.

    (@mindshare)

    The next release will allow you to disable automatic updates using an action. Until then you can turn off auto updates per this post and see if that fixes the issue:

    https://www.ads-software.com/support/topic/warning-and-fatal-error-7?replies=5#post-6040976

    I tried turning off auto updates and after about 6 days of uptime on our production server, I got the following error with the site down:

    [Mon Sep 29 09:38:47 2014] [error] [client 10.4.26.238] PHP Warning:  touch(): Utime failed: Operation not permitted in /.../plugins/php-browser-detection/lib/Browscap.php on line 295
    
    [Mon Sep 29 09:38:47 2014] [error] [client 10.4.26.238] PHP Fatal error:  Uncaught exception 'phpbrowscap\\Exception' with message 'Could not write .ini content to /.../plugins/php-browser-detection/cache/browscap.ini' in /.../plugins/php-browser-detection/lib/Browscap.php:839\n
    Stack trace:\n
    #0 /.../plugins/php-browser-detection/lib/Browscap.php(504): phpbrowscap\\Browscap->_getRemoteIniFile('https://browscap...', '/srv/websites/i...')\n
    #1 /.../plugins/php-browser-detection/lib/Browscap.php(291): phpbrowscap\\Browscap->updateCache()\n
    #2 /.../plugins/php-browser-detection/php-browser-detection.php(56): phpbrowscap\\Browscap->getBrowser(NULL, true)\n
    #3 /.../plugins/php-browser-detection/php-browser-detection.php(89): php_browser_info()\n
    #4 /.../plugins/php-browser-detection/php-browser-detection.php(157): is_browser('IE', 8)\n
    #5 in /.../plugins/php-browser-detection/lib/Browscap.php on line 839

    This is regarding the same site that Spinfly is having issues with. Any ideas?

    Plugin Author Mindshare Labs, Inc.

    (@mindshare)

    Those errors are definitely being triggered by the update process. I bet there is another place in the code you will need to change. I am going to try to push out a new version today though, so standby for the update.

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘Out of memory errors’ is closed to new replies.