本文整理汇总了PHP中gc_collect_cycles函数的典型用法代码示例。如果您正苦于以下问题:PHP gc_collect_cycles函数的具体用法?PHP gc_collect_cycles怎么用?PHP gc_collect_cycles使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了gc_collect_cycles函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: run
public function run(array $argv, $exit = true, $memoryTracking = true, $bootstrap = null)
{
require_once __DIR__ . '/../printer/SerializePrinter.php';
$this->arguments['printer'] = $this->handlePrinter('phpunit_parallel\\printer\\SerializePrinter');
if ($bootstrap) {
$this->arguments['bootstrap'] = $bootstrap;
}
$this->handleConfig();
$runner = $this->createRunner();
while ($testDetails = fgets(STDIN)) {
if ($memoryTracking) {
gc_collect_cycles();
}
if ($request = TestRequest::decode($testDetails)) {
SerializePrinter::getInstance()->setCurrentRequest($request);
$escapedClassName = str_replace('\\', '\\\\', $request->getClass());
$this->arguments['filter'] = "^{$escapedClassName}::{$request->getName()}\$";
$suite = new \PHPUnit_Framework_TestSuite($request->getClass());
$suite->addTestFile($request->getFilename());
$result = $runner->doRun($suite, $this->arguments);
if ($result->count() === 0) {
$this->showError($request, "Test not found!");
} elseif ($result->count() > 1) {
$this->showError($request, "Multiple tests executed!");
}
}
}
return 0;
}
开发者ID:vektah,项目名称:phpunit-parallel,代码行数:29,代码来源:PhpunitWorkerCommand.php
示例2: run
/**
* Runtime of Master process
* @return void
*/
protected function run()
{
Daemon::$process = $this;
$this->prepareSystemEnv();
class_exists('Timer');
// ensure loading this class
gc_enable();
/* This line must be commented according to current libevent binding implementation. May be uncommented in future. */
//$this->eventBase = new \EventBase;
if ($this->eventBase) {
$this->registerEventSignals();
} else {
$this->registerSignals();
}
$this->workers = new Collection();
$this->collections['workers'] = $this->workers;
$this->ipcthreads = new Collection();
$this->collections['ipcthreads'] = $this->ipcthreads;
Daemon::$appResolver->preload(true);
$this->callbacks = new StackCallbacks();
$this->spawnIPCThread();
$this->spawnWorkers(min(Daemon::$config->startworkers->value, Daemon::$config->maxworkers->value));
$this->timerCb = function ($event) use(&$cbs) {
static $c = 0;
++$c;
if ($c > 0xfffff) {
$c = 1;
}
if ($c % 10 == 0) {
gc_collect_cycles();
}
if (!$this->lastMpmActionTs || microtime(true) - $this->lastMpmActionTs > $this->minMpmActionInterval) {
$this->callMPM();
}
if ($event) {
$event->timeout();
}
};
if ($this->eventBase) {
// we are using libevent in Master
Timer::add($this->timerCb, 1000000.0 * Daemon::$config->mpmdelay->value, 'MPM');
while (!$this->breakMainLoop) {
$this->callbacks->executeAll($this);
if (!$this->eventBase->dispatch()) {
break;
}
}
} else {
// we are NOT using libevent in Master
$lastTimerCall = microtime(true);
while (!$this->breakMainLoop) {
$this->callbacks->executeAll($this);
if (microtime(true) > $lastTimerCall + Daemon::$config->mpmdelay->value) {
call_user_func($this->timerCb, null);
$lastTimerCall = microtime(true);
}
$this->sigwait();
}
}
}
开发者ID:shamahan,项目名称:phpdaemon,代码行数:64,代码来源:Master.php
示例3: onRequest
public function onRequest($stream, $remote_addr)
{
$this->in_request = true;
if (false === $this->protocol->readRequest($stream, $remote_addr)) {
return;
}
$context = array('env' => $this->protocol->getHeaders(), 'stdin' => $this->protocol->getStdin(), 'logger' => function ($message) {
echo $message . "\n";
});
$result = call_user_func($this->app, $context);
unset($context);
if (!is_array($result) or count($result) != 3) {
throw new BadProtocolException("App did not return proper result");
}
try {
$this->protocol->writeResponse($result);
} catch (NoStreamException $e) {
$this->log('output stream is gone. cleaning up');
}
// cleanup
unset($result);
$this->protocol->doneWithRequest();
$this->in_request = false;
gc_collect_cycles();
if ($this->should_stop) {
die;
}
}
开发者ID:LookForwardPersistence,项目名称:appserver-in-php,代码行数:28,代码来源:Daemonic.php
示例4: tearDown
public function tearDown()
{
parent::tearDown();
// without forcing garbage collection, the DB connections
// are not guaranteed to be disconnected; force GC
gc_collect_cycles();
}
开发者ID:lightster,项目名称:hodor,代码行数:7,代码来源:PostgresProvisioner.php
示例5: testHydrationPerformance
/**
* [jwage: 10000 objects in ~6 seconds]
*/
public function testHydrationPerformance()
{
$s = microtime(true);
$batchSize = 20;
for ($i = 1; $i <= 10000; ++$i) {
$user = new CmsUser();
$user->status = 'user';
$user->username = 'user' . $i;
$user->name = 'Mr.Smith-' . $i;
$this->dm->persist($user);
if ($i % $batchSize == 0) {
$this->dm->flush();
$this->dm->clear();
}
}
gc_collect_cycles();
echo "Memory usage before: " . memory_get_usage() / 1024 . " KB" . PHP_EOL;
$users = $this->dm->getRepository('Documents\\CmsUser')->findAll();
foreach ($users as $user) {
}
$this->dm->clear();
gc_collect_cycles();
echo "Memory usage after: " . memory_get_usage() / 1024 . " KB" . PHP_EOL;
$e = microtime(true);
echo 'Hydrated 10000 objects in ' . ($e - $s) . ' seconds' . PHP_EOL;
}
开发者ID:Wizkunde,项目名称:mongodb-odm,代码行数:29,代码来源:HydrationPerformanceTest.php
示例6: execute
/**
* @see Command
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$db = $this->getContainer()->get('doctrine')->getManager();
$importlogfile = "import.correct.machines.distributions";
$distributions = $db->getRepository('SywFrontMainBundle:Distributions')->findByLower('machinesnum', '50');
foreach ($distributions as $distribution) {
$machines = null;
unset($machines);
$machines = $distribution->getMachines();
$mnum = count($machines);
$desc = $distribution->getDescription();
if ($mnum <= 49 && ($desc == null || trim($desc) == "")) {
$mnum = -999999;
foreach ($machines as $machine) {
$machine->setDistribution(null);
$db->persist($machine);
}
}
$distribution->setMachinesNum($mnum);
$db->persist($distribution);
$db->flush();
gc_collect_cycles();
}
gc_collect_cycles();
}
开发者ID:Jheengut,项目名称:linuxcounter.new,代码行数:28,代码来源:CorrectMachinesDistributionsCommand.php
示例7: init
public function init($vars, $class = __CLASS__)
{
$this->calle = '';
$this->departamento = '';
$this->piso = '';
$this->numero = '';
if (isset($vars)) {
$reflexion = new ReflectionClass($this);
foreach ($vars as $key => $value) {
foreach ($reflexion->getMethods() as $reflexion_method) {
if ($reflexion_method->name == 'set_' . $key) {
$this->{"set_" . $key}($value);
}
}
if ($key == 'id_localizacion') {
$this->set_id($value);
}
}
unset($reflexion);
/*
foreach ($vars as $key => $value){
if(array_key_exists($key, get_class_vars($class))){
if(method_exists($this, "set_" . $key)){
$this->{"set_". $key}($value);
}
}
if($key == 'id_localizacion') {
$this->set_id($value);
}
}
*/
}
gc_collect_cycles();
}
开发者ID:jpasosa,项目名称:global,代码行数:34,代码来源:localizacion.php
示例8: parse
public function parse($source, $type = 'file', $is_object = true)
{
if ('file' === $type and $this->isRelativePath($source)) {
$source = $this->path('config', $source);
}
$resolve = [];
foreach ($this->path as $tag => $ignored) {
$resolve['!' . $tag . '_path'] = function ($value) use($tag) {
return $this->path($tag, $value);
};
}
foreach (get_class_methods($this) as $method) {
if (0 === strpos($method, '__resolve_')) {
$tag = substr($method, strlen('__resolve_'));
$resolve['!' . $tag] = [$this, $method];
}
}
$parse = ['file' => 'yaml_parse_file', 'url' => 'yaml_parse_url', 'string' => 'yaml_parse'][$type];
$out = $parse($source, 0, $ignored, $resolve);
if ($is_object) {
$class =& $out['class'];
unset($out['class']);
$out = $class ? new $class($out) : new Factory($out);
}
gc_collect_cycles();
return $out;
}
开发者ID:noframework,项目名称:noframework,代码行数:27,代码来源:Config.php
示例9: import
public function import($file, OutputInterface $output)
{
$csvFile = new CsvFile($file);
$csv = $csvFile->getCsv();
$progress = new ProgressBar($output, 100);
$progress->start();
$cpt = 0;
$cptTotal = 0;
foreach ($csv as $data) {
$etablissement = $this->createFromImport($data, $output);
if (!$etablissement) {
continue;
}
$this->dm->persist($etablissement);
$cptTotal++;
if ($cptTotal % (count($csv) / 100) == 0) {
$progress->advance();
}
if ($cpt > 1000) {
$this->dm->flush();
$this->dm->clear();
gc_collect_cycles();
$cpt = 0;
}
$cpt++;
}
$this->dm->flush();
$progress->finish();
}
开发者ID:24eme,项目名称:aurouze,代码行数:29,代码来源:EtablissementCsvImporter.php
示例10: clearMemory
public function clearMemory()
{
accessControlPeer::clearInstancePool();
BatchJobPeer::clearInstancePool();
BulkUploadResultPeer::clearInstancePool();
categoryPeer::clearInstancePool();
EmailIngestionProfilePeer::clearInstancePool();
entryPeer::clearInstancePool();
FileSyncPeer::clearInstancePool();
flavorAssetPeer::clearInstancePool();
flavorParamsConversionProfilePeer::clearInstancePool();
flavorParamsOutputPeer::clearInstancePool();
flavorParamsPeer::clearInstancePool();
kshowPeer::clearInstancePool();
mediaInfoPeer::clearInstancePool();
moderationFlagPeer::clearInstancePool();
moderationPeer::clearInstancePool();
notificationPeer::clearInstancePool();
roughcutEntryPeer::clearInstancePool();
SchedulerConfigPeer::clearInstancePool();
SchedulerPeer::clearInstancePool();
SchedulerStatusPeer::clearInstancePool();
SchedulerWorkerPeer::clearInstancePool();
StorageProfilePeer::clearInstancePool();
syndicationFeedPeer::clearInstancePool();
TrackEntryPeer::clearInstancePool();
uiConfPeer::clearInstancePool();
UploadTokenPeer::clearInstancePool();
// TODO clear default filters
// TODO call all memory cleaner plugins
if (function_exists('gc_collect_cycles')) {
// php 5.3 and above
gc_collect_cycles();
}
}
开发者ID:richhl,项目名称:kalturaCE,代码行数:35,代码来源:KalturaDispatcher.php
示例11: fire
/**
* Execute the console command.
*
* @return mixed
*/
public function fire()
{
$points = DestinationPoint::with(['city', 'country'])->whereNull('destination_points.latitude')->orderBy('id')->get();
$count = 0;
foreach ($points as $point) {
$count++;
if (0 == $count % 1000) {
$unprocessed_points = DestinationPoint::with(['city', 'country'])->whereNull('destination_points.latitude')->count();
$collected_cycles_count = gc_collect_cycles();
$this->comment($unprocessed_points . ' unprocessed destination points (' . $this->getMemoryUsage() . ' / ' . $collected_cycles_count . ' cycles)');
}
if (!($country = $point->country()->first())) {
return $this->error("Skipped point #{$point->id}: country not found");
}
if (!($city = $point->city()->first())) {
return $this->error("Skipped point #{$point->id}: city not found");
}
$address = $point->address;
if (false === mb_strpos($address, $city->name)) {
$address = $city->name . ', ' . $address;
}
if (false === mb_strpos($address, $country->name)) {
$address = $country->name . ', ' . $address;
}
try {
if ($point = $this->geocode($point, $address)) {
$point->save();
}
} catch (ChainNoResultException $e) {
$this->error("Not founded {$address}");
}
}
return;
}
开发者ID:Nebo15,项目名称:ariadne.api,代码行数:39,代码来源:GeocodePoints.php
示例12: tearDown
protected function tearDown()
{
//Close & unsets
if (is_object($this->em)) {
$this->em->getConnection()->close();
$this->em->close();
}
unset($this->em);
unset($this->container);
unset($this->kern);
unset($this->client);
//Nettoyage des mocks
//http://kriswallsmith.net/post/18029585104/faster-phpunit
$refl = new \ReflectionObject($this);
foreach ($refl->getProperties() as $prop) {
if (!$prop->isStatic() && 0 !== strpos($prop->getDeclaringClass()->getName(), 'PHPUnit_')) {
$prop->setAccessible(true);
$prop->setValue($this, null);
}
}
//Nettoyage du garbage
if (!gc_enabled()) {
gc_enable();
}
gc_collect_cycles();
//Parent
parent::tearDown();
}
开发者ID:Reallymute,项目名称:IRMApplicative,代码行数:28,代码来源:CarmaWebTestCase.php
示例13: tearDown
protected function tearDown()
{
// Unset to keep database connections from piling up.
$this->backend = null;
// Collect garbages manually to free up connections.
gc_collect_cycles();
}
开发者ID:kankje,项目名称:xi-filelib,代码行数:7,代码来源:AbstractBackendAdapterTestCase.php
示例14: flush
/**
* Flush image data from memory.
*
* @param bool $collect_garbage
*/
public function flush($collect_garbage = true)
{
$this->data = null;
if ($collect_garbage) {
gc_collect_cycles();
}
}
开发者ID:bravo3,项目名称:image-manager,代码行数:12,代码来源:Image.php
示例15: tearDown
public function tearDown()
{
$this->as = null;
$this->ccm = null;
$this->executor = null;
gc_collect_cycles();
}
开发者ID:futoin,项目名称:core-php-ri-executor,代码行数:7,代码来源:ExecutorTest.php
示例16: dataNone
public function dataNone(UnitTester $I)
{
$I->wantTo("Use Memory cache with None frontend");
$frontend = new None(['lifetime' => 10]);
$backend = new Memory($frontend);
$I->assertFalse($backend->isStarted());
$backend->save('test-data', 'nothing interesting');
$I->assertEquals('nothing interesting', $backend->get('test-data'));
$backend->save('test-data', 'something interesting');
$I->assertEquals('something interesting', $backend->get('test-data'));
$I->assertTrue($backend->exists('test-data'));
$I->assertTrue($backend->delete('test-data'));
$string = str_repeat('a', 5000000);
$backend->save('test-data', $string);
$s1 = $backend->get('test-data');
$s2 = $backend->get('test-data');
$s3 = $backend->get('test-data');
$I->assertEquals($s1, $s2);
$I->assertEquals($s1, $s3);
$I->assertEquals(strlen($s1), 5000000);
$I->assertEquals($s1, $string);
$I->assertTrue($backend->delete('test-data'));
unset($s1, $s2, $s3);
gc_collect_cycles();
$s1 = $frontend->afterRetrieve($string);
$s2 = $frontend->afterRetrieve($string);
$s3 = $frontend->afterRetrieve($string);
$I->assertEquals($s1, $s2);
$I->assertEquals($s1, $s3);
$I->assertEquals($s1, $string);
}
开发者ID:mattvb91,项目名称:cphalcon,代码行数:31,代码来源:MemoryCest.php
示例17: activate
/**
* Creates groups for registered users.
* Must be called explicitly or hooked into activation.
*/
public static function activate()
{
global $wpdb;
// create a group for the blog if it doesn't exist
if (!($group = Groups_Group::read_by_name(self::REGISTERED_GROUP_NAME))) {
$group_id = Groups_Group::create(array("name" => self::REGISTERED_GROUP_NAME));
} else {
$group_id = $group->group_id;
}
if ($group_id) {
$n = $wpdb->get_var("SELECT COUNT(ID) FROM {$wpdb->users}");
for ($i = 0; $i < $n; $i += self::BATCH_LIMIT) {
$users = $wpdb->get_results($wpdb->prepare("SELECT ID FROM {$wpdb->users} LIMIT %d, %d", $i, self::BATCH_LIMIT));
foreach ($users as $user) {
// add the user to the group
if (!Groups_User_Group::read($user->ID, $group_id)) {
Groups_User_Group::create(array("user_id" => $user->ID, "group_id" => $group_id));
}
}
unset($users);
if (function_exists('gc_collect_cycles')) {
gc_collect_cycles();
}
}
}
}
开发者ID:solsticehc,项目名称:solsticehc,代码行数:30,代码来源:class-groups-registered.php
示例18: run
/**
* {@inheritDoc}
*/
public function run(callable $onStart = null)
{
if ($this->state !== self::STOPPED) {
throw new \LogicException("Cannot run() recursively; event reactor already active");
}
if ($onStart) {
$this->state = self::STARTING;
$onStartWatcherId = $this->immediately($onStart);
$this->tryImmediate($this->watchers[$onStartWatcherId]);
if (empty($this->keepAliveCount) && empty($this->stopException)) {
$this->state = self::STOPPED;
}
} else {
$this->state = self::RUNNING;
}
while ($this->state > self::STOPPED) {
$immediates = $this->immediates;
foreach ($immediates as $watcher) {
if (!$this->tryImmediate($watcher)) {
break;
}
}
if (empty($this->keepAliveCount) || $this->state <= self::STOPPED) {
break;
}
\uv_run($this->loop, $this->immediates ? \UV::RUN_NOWAIT : \UV::RUN_ONCE);
}
\gc_collect_cycles();
$this->state = self::STOPPED;
if ($this->stopException) {
$e = $this->stopException;
$this->stopException = null;
throw $e;
}
}
开发者ID:nimmen,项目名称:amp,代码行数:38,代码来源:UvReactor.php
示例19: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$startTime = microtime(true);
$batchSize = 1000;
$em = $this->getContainer()->get('doctrine')->getEntityManager();
$repository = $this->getContainer()->get('doctrine')->getRepository('AppBundle:Student');
$students = $repository->getStudents();
$i = 0;
while (($row = $students->next()) !== false) {
$student = $row[0];
$student->setPath($this->getContainer()->get('get.path')->getPath($student));
$i++;
if ($i % $batchSize === 0) {
echo memory_get_usage() / 1048576 . 'MB';
echo "\r\n";
$em->flush();
$em->clear();
gc_collect_cycles();
}
}
$em->flush();
echo "\r\n";
$endTime = microtime(true);
echo $endTime - $startTime;
}
开发者ID:colinbleach,项目名称:University,代码行数:25,代码来源:GeneratePathCommand.php
示例20: run
/**
* {@inheritDoc}
*/
public function run(callable $onStart = null)
{
if ($this->state !== self::STOPPED) {
throw new \LogicException("Cannot run() recursively; event reactor already active");
}
if ($onStart) {
$this->state = self::STARTING;
$watcherId = $this->immediately($onStart);
if (!$this->tryImmediate($this->watchers[$watcherId]) || empty($this->keepAliveCount)) {
return;
}
} else {
$this->state = self::RUNNING;
}
$this->enableTimers();
while ($this->state > self::STOPPED) {
$this->doTick($noWait = false);
if (empty($this->keepAliveCount)) {
break;
}
}
\gc_collect_cycles();
$this->timersEnabled = false;
$this->state = self::STOPPED;
}
开发者ID:nimmen,项目名称:amp,代码行数:28,代码来源:NativeReactor.php
注:本文中的gc_collect_cycles函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论