本文整理汇总了PHP中OX_increaseMemoryLimit函数的典型用法代码示例。如果您正苦于以下问题:PHP OX_increaseMemoryLimit函数的具体用法?PHP OX_increaseMemoryLimit怎么用?PHP OX_increaseMemoryLimit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了OX_increaseMemoryLimit函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* A method to run maintenance.
*/
function run()
{
// Print a blank line in the debug log file when maintenance starts
OA::debug();
// Do not run if distributed stats are enabled
if (!empty($this->aConf['lb']['enabled'])) {
OA::debug('Distributed stats enabled, not running maintenance tasks', PEAR_LOG_INFO);
return;
}
// Acquire the maintenance lock
$oLock =& OA_DB_AdvisoryLock::factory();
if ($oLock->get(OA_DB_ADVISORYLOCK_MAINTENANCE)) {
OA::switchLogIdent('maintenance');
OA::debug();
OA::debug('Running Maintenance Engine', PEAR_LOG_INFO);
// Attempt to increase PHP memory
OX_increaseMemoryLimit(OX_getMinimumRequiredMemory('maintenance'));
// Set UTC timezone
OA_setTimeZoneUTC();
// Get last run
$oLastRun = $this->getLastRun();
// Update the timestamp for old maintenance code and auto-maintenance
$this->updateLastRun();
// Record the current time, and register with the OA_ServiceLocator
$oDate = new Date();
$oServiceLocator =& OA_ServiceLocator::instance();
$oServiceLocator->register('now', $oDate);
// Check the operation interval is valid
$result = OX_OperationInterval::checkOperationIntervalValue($this->aConf['maintenance']['operationInterval']);
if (PEAR::isError($result)) {
// Unable to continue!
$oLock->release();
OA::debug('Aborting maintenance: Invalid Operation Interval length', PEAR_LOG_CRIT);
exit;
}
// Run the Maintenance Statistics Engine (MSE) process
$this->_runMSE();
// Run the "midnight" tasks, if required
if ($this->isMidnightMaintenance($oLastRun)) {
$this->_runMidnightTasks();
}
// Release lock before starting MPE
$oLock->release();
// Run the Maintenance Priority Engine (MPE) process, ensuring that the
// process always runs, even if instant update of priorities is disabled
$this->_runMPE();
// Log the completion of the entire ME process
OA::switchLogIdent('maintenance');
$oEndDate = new Date();
$oDateSpan = new Date_Span();
$oDateSpan->setFromDateDiff($oDate, $oEndDate);
OA::debug('Maintenance Engine Completed (Started at ' . $oDate->format('%Y-%m-%d %H:%M:%S') . ' ' . $oDate->tz->getShortName() . ', taking ' . $oDateSpan->format('%H:%M:%S') . ')', PEAR_LOG_INFO);
OA::switchLogIdent();
} else {
OA::switchLogIdent('maintenance');
OA::debug('Maintenance Engine not run: could not acquire lock', PEAR_LOG_INFO);
OA::switchLogIdent();
}
}
示例2: init
function init()
{
$aConf = $GLOBALS['_MAX']['CONF'];
$this->pathPackages = $aConf['pluginPaths']['packages'];
$this->pathPlugins = $aConf['pluginPaths']['plugins'];
$this->pathPluginsAdmin = $aConf['pluginPaths']['admin'];
$this->pathDataObjects = $aConf['pluginPaths']['var'] . 'DataObjects/';
// Attempt to increase the memory limit when using the plugin manager
OX_increaseMemoryLimit(OX_getMinimumRequiredMemory('plugin'));
$this->basePath = MAX_PATH;
}
示例3: OX_checkMemoryCanBeSet
/**
* Test if the memory_limit can be changed.
*
* @return boolean True if the memory_limit can be changed, false otherwise.
*/
function OX_checkMemoryCanBeSet()
{
$phpMemoryLimitInBytes = OX_getMemoryLimitSizeInBytes();
// Unlimited memory, no need to check if it can be set
if ($phpMemoryLimitInBytes == -1) {
return true;
}
OX_increaseMemoryLimit($phpMemoryLimitInBytes + 1);
$newPhpMemoryLimitInBytes = OX_getMemoryLimitSizeInBytes();
$memoryCanBeSet = $phpMemoryLimitInBytes != $newPhpMemoryLimitInBytes;
// Restore previous limit
@ini_set('memory_limit', $phpMemoryLimitInBytes);
return $memoryCanBeSet;
}
示例4: run
/**
* A method to run distributed maintenance.
*/
function run()
{
if (empty($GLOBALS['_MAX']['CONF']['lb']['enabled'])) {
OA::debug('Distributed stats disabled, not running Maintenance Distributed Engine', PEAR_LOG_INFO);
return;
}
if (!empty($GLOBALS['_MAX']['CONF']['rawDatabase'])) {
$GLOBALS['_MAX']['CONF']['database'] = $GLOBALS['_MAX']['CONF']['rawDatabase'] + $GLOBALS['_MAX']['CONF']['database'];
OA::debug('rawDatabase functionality is being used, switching settings', PEAR_LOG_INFO);
}
$oLock =& OA_DB_AdvisoryLock::factory();
if (!$oLock->get(OA_DB_ADVISORYLOCK_DISTRIBUTED)) {
OA::debug('Maintenance Distributed Engine Already Running', PEAR_LOG_INFO);
return;
}
OA::debug('Running Maintenance Distributed Engine', PEAR_LOG_INFO);
// Attempt to increase PHP memory
OX_increaseMemoryLimit(OX_getMinimumRequiredMemory('maintenance'));
// Ensure the current time is registered with the OA_ServiceLocator
$oServiceLocator =& OA_ServiceLocator::instance();
$oNow =& $oServiceLocator->get('now');
if (!$oNow) {
// Record the current time, and register with the OA_ServiceLocator
$oNow = new Date();
$oServiceLocator->register('now', $oNow);
}
OA::debug(' - Current time is ' . $oNow->format('%Y-%m-%d %H:%M:%S') . ' ' . $oNow->tz->getShortName(), PEAR_LOG_DEBUG);
// Get the components of the deliveryLog extension
$aBuckets = OX_Component::getComponents('deliveryLog');
// Copy buckets' records with "interval_start" up to and including previous OI start,
// and then prune the data processed
$aPreviousOperationIntervalDates = OX_OperationInterval::convertDateToPreviousOperationIntervalStartAndEndDates($oNow);
OA::debug(' - Will process data for all operation intervals before and up to start', PEAR_LOG_DEBUG);
OA::debug(' time of ' . $aPreviousOperationIntervalDates['start']->format('%Y-%m-%d %H:%M:%S') . ' ' . $aPreviousOperationIntervalDates['start']->tz->getShortName(), PEAR_LOG_DEBUG);
foreach ($aBuckets as $sBucketName => $oBucketClass) {
if ($oBucketClass->testStatisticsMigration($oBucketClass->getStatisticsMigration())) {
$oBucketClass->processBucket($aPreviousOperationIntervalDates['start']);
$oBucketClass->pruneBucket($aPreviousOperationIntervalDates['start']);
} else {
OA::debug(' - Skipping ' . $sBucketName, PEAR_LOG_DEBUG);
}
}
$oLock->release();
OA::debug('Maintenance Distributed Engine Completed', PEAR_LOG_INFO);
}
示例5: OX_checkMemoryCanBeSet
function OX_checkMemoryCanBeSet()
{
$phpMemoryLimitInBytes = OX_getMemoryLimitSizeInBytes();
if ($phpMemoryLimitInBytes == -1) {
return true;
}
OX_increaseMemoryLimit($phpMemoryLimitInBytes + 1);
$newPhpMemoryLimitInBytes = OX_getMemoryLimitSizeInBytes();
$memoryCanBeSet = $phpMemoryLimitInBytes != $newPhpMemoryLimitInBytes;
@ini_set('memory_limit', $phpMemoryLimitInBytes);
return $memoryCanBeSet;
}
示例6: OX_increaseMemoryLimit
* @author Radek Maciaszek <radek.maciaszek@openx.org>
*
* A file to set up the environment for the delivery engine.
*
* Both opcode and PHP by itself slow things down when we require many
* files. Therefore we gave up a little bit of maintainability in
* order to speed up a delivery:
* - We are not using classes (if possible) in delivery
* - We have to use as few as possible includes and add new code into
* existing files
*/
require_once 'init-delivery-parse.php';
require_once 'memory.php';
require_once 'variables.php';
// Increase the PHP memory_limit value to the minimum required value, if necessery
OX_increaseMemoryLimit(OX_getMinimumRequiredMemory());
// PHP 5.3 compatibility
if (!defined('E_DEPRECATED')) {
define('E_DEPRECATED', 0);
}
setupServerVariables();
setupDeliveryConfigVariables();
$conf = $GLOBALS['_MAX']['CONF'];
// Set this script's identifier (from the config file) in the global scope
$GLOBALS['_OA']['invocationType'] = array_search(basename($_SERVER['SCRIPT_FILENAME']), $conf['file']);
// Disable all notices and warnings,
// as some PAN code still generates PHP warnings in places
if (!empty($conf['debug']['production'])) {
error_reporting(E_ALL & ~(E_NOTICE | E_WARNING | E_DEPRECATED | E_STRICT));
} else {
// show all errors when developing
示例7: phpAds_PageHeader
phpAds_PageHeader("maintenance-index");
phpAds_MaintenanceSelection("acls");
/*-------------------------------------------------------*/
/* Main code */
/*-------------------------------------------------------*/
if (!empty($action) && $action == 'Recompile') {
MAX_AclReCompileAll();
echo "<strong>{$strAllBannerChannelCompiled}</strong><br />";
}
echo $strBannerChannelResult;
phpAds_ShowBreak();
// Check the ACLs in the database against the compiled limitation strings...
echo "<strong>" . $strChannels . ":</strong>";
phpAds_showBreak();
// Check all the channels...
OX_increaseMemoryLimit(OX_getMinimumRequiredMemory('maintenance'));
$dalChannel = OA_Dal::factoryDAL('channel');
$rsChannel = $dalChannel->getChannelsAndAffiliates();
$rsChannel->find();
$allChannelsValid = true;
while ($rsChannel->fetch() && ($row = $rsChannel->toArray())) {
if (!MAX_AclValidate('channel-acl.php', array('channelid' => $row['channelid']))) {
$allChannelsValid = false;
$affiliateName = !empty($row['affiliatename']) ? $row['affiliatename'] : $strUntitled;
echo "<a href='channel-acl.php?affiliateid={$row['affiliateid']}&channelid={$row['channelid']}'>{$row['name']}</a><br />";
}
}
if ($allChannelsValid) {
echo $strChannelCompiledLimitationsValid;
}
phpAds_showBreak();
示例8: run
/**
* The method to run the Maintenance Priority Engine process.
*
* @static
* @param boolean $alwaysRun Default value is false. If true, the Maintenance
* Priority Engine process will always run, even if
* instant priority updates have been disabled in the
* configuration. Used to ensure that the maintenance
* script process can always update priorities.
* @return boolean True on MPE running correctly, false otherwise.
*/
function run($alwaysRun = false)
{
OA::switchLogIdent('maintenance');
// Get the configuration
$aConf = $GLOBALS['_MAX']['CONF'];
// Should the MPE process run?
if (!$alwaysRun) {
// Is instant update for priority set?
if (!$aConf['priority']['instantUpdate']) {
OA::debug('Instant update of priorities disabled, not running MPE', PEAR_LOG_INFO);
return false;
}
OA::debug();
}
// Log the start of the process
OA::debug('Running Maintenance Priority Engine', PEAR_LOG_INFO);
// Set longer time out, and ignore user abort
if (!ini_get('safe_mode')) {
@set_time_limit($aConf['maintenance']['timeLimitScripts']);
@ignore_user_abort(true);
}
// Attempt to increase PHP memory
OX_increaseMemoryLimit(OX_getMinimumRequiredMemory('maintenance'));
// Run the following code as the "Maintenance" user
OA_Permission::switchToSystemProcessUser('Maintenance');
// Create a Maintenance DAL object
$oDal = new OA_Dal_Maintenance_Priority();
// Try to get the MPE database-level lock
$lock = $oDal->obtainPriorityLock();
if (!$lock) {
OA::debug('Unable to obtain database-level lock, not running MPE', PEAR_LOG_ERR);
return false;
}
// Ensure the the current time is registered with the OA_ServiceLocator
$oServiceLocator =& OA_ServiceLocator::instance();
$oDate =& $oServiceLocator->get('now');
if (!$oDate) {
// Record the current time, and register with the OA_ServiceLocator
$oDate = new Date();
$oServiceLocator->register('now', $oDate);
}
// Run the MPE process for the AdServer module
require_once MAX_PATH . '/lib/OA/Maintenance/Priority/AdServer.php';
$oMaintenancePriority = new OA_Maintenance_Priority_AdServer();
// TODO: OA_Maintenance_Priority_AdServer::updatePriorities
// should be refactored to return a boolean we can check here.
$oMaintenancePriority->updatePriorities();
// Release the MPE database-level lock
$result = $oDal->releasePriorityLock();
if (PEAR::isError($result)) {
// Unable to continue!
OA::debug('Unable to release database-level lock', PEAR_LOG_ERR);
return false;
}
// Return to the "normal" user
OA_Permission::switchToSystemProcessUser();
// Log the end of the process
OA::debug('Maintenance Priority Engine Completed (Started at ' . $oDate->format('%Y-%m-%d %H:%M:%S') . ' ' . $oDate->tz->getShortName() . ')', PEAR_LOG_INFO);
OA::switchLogIdent();
return true;
}