I was using WURFL just fine, then all of a sudden it's throwing this error:
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 65484 bytes) in /var/wwwlibs/vnd/WURFL/lib/CustomDevice.php on line 118
I've found some stuff online about Tera-WURFL, but (afaik) I'm not using that, but just the downloaded version from sourceforge. Someone suggested updating the SimpleXML, but I'm just confused as to why WURFL's going over the top.
My wrapper class is as follows:
<?php
namespace vnd\WURFL;
use \WURFL_Configuration_InMemoryConfig;
use \WURFL_WURFLManagerFactory;
/**
* File: WURFL_bootstrap.php
* Sets up and readies the WURFL library for platform and browser detection.
*/
require_once 'WURFL/lib/Application.php';
// ----- WURFL constants ------ //
define('WURFL_ROOT', dirname(__FILE__).'/');
# Directories
define('WURFL_RESOURCES_DIR', WURFL_ROOT.'resources/');
define('WURFL_PERSISTENCE_DIR', WURFL_RESOURCES_DIR.'storage/persistence');
define('WURFL_CACHE_DIR', WURFL_RESOURCES_DIR.'storage/cache');
class WURFLBootstrap extends WURFL_Configuration_InMemoryConfig {
const WURFL_WATCH_MODE = "performance";
const WURFL_VERSION = '2.3.3';
const WURFL_CACHE_EXP = 36000;
# Our WURFL Manager
private $_manager;
# Our device where the capabilities lie
private $_device;
public function __construct(){
$zipPath = $this->getPath();
if(!is_file($zipPath))
die($zipPath.' is not a valid file.');
if(!is_dir(WURFL_PERSISTENCE_DIR) || !is_dir(WURFL_CACHE_DIR))
die(WURFL_PERSISTENCE_DIR.' or '.WURFL_CACHE_DIR.' are not valid directories.');
$this->wurflFile($zipPath);
$this->matchMode(self::WURFL_WATCH_MODE);
$this->persistence('file', array('dir' => WURFL_PERSISTENCE_DIR));
$this->cache('file', array('dir' => WURFL_CACHE_DIR, 'expiration' => self::WURFL_CACHE_EXP));
// Automatically reload the WURFL data if it changes
$this->allowReload(true);
// Create a WURFL Manager Factory from the WURFL Configuration
$wurflManagerFactory = new WURFL_WURFLManagerFactory($this);
// Create our factory and start the process.
$this->_device = $wurflManagerFactory->create()->getDeviceForHttpRequest($_SERVER);
}
/**
* Returns the path to our ZIP file
*/
private function getPath(){
return WURFL_RESOURCES_DIR.'/wurfl-'.self::WURFL_VERSION.'.zip';
}
/**
* Seeing as this is a wrapper class, any calls to our $wflManager (or whatever
* we happened to be assigned to) should be passed on to the actual
* manager object where all the goodies lie.
*
*/
public function __call($name, $arguments){
//return $this->device->$name($arguments);
}
public function getDevice(){
return $this->_device;
}
}
The computer this is running on is an old laptop, so it's not stocked on memory, but what gives? I removed everything that could be causing an over-allocation of memory, but so far it seems like WURFL just doesn't want to run.
I also tried clearing my cache and persistence directories and running it again, but no dice.
One thing I'm thinking is to use the XML configuration class as opposed to the WURFL_Configuration_InMemoryConfig
(based on the name I assume it's storing everything in memory, at least temporarily, hence the crash), but I'm curious why it's all of a sudden throwing this error.