【问题标题】:symfony : how to check bundles memory usagesymfony:如何检查捆绑包的内存使用情况
【发布时间】:2015-12-20 02:37:19
【问题描述】:

在我的 symfony 应用程序中,当我在操作开始时或在 app_dev.php 的 $response = $kernel->handle($request); 之后转储 php 内存使用情况时,我得到它使用了大约 60Mb 的内存。使用 app.php 时也是如此。

我知道这太多了,所以我试图了解如何更正我的申请。

有没有办法可以转储每个捆绑包的内存使用情况?我还没有找到简单的方法。

我的捆绑清单:

    public function registerBundles()
    {
        $bundles = array(
            new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
            new Symfony\Bundle\SecurityBundle\SecurityBundle(),
            new Symfony\Bundle\TwigBundle\TwigBundle(),
            new Symfony\Bundle\MonologBundle\MonologBundle(),
            new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
            new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
            new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
            new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(),
            new FOS\ElasticaBundle\FOSElasticaBundle(),
            new FOS\UserBundle\FOSUserBundle(),
            new Genemu\Bundle\FormBundle\GenemuFormBundle(),
            new Gregwar\CaptchaBundle\GregwarCaptchaBundle(),
            new Ivory\OrderedFormBundle\IvoryOrderedFormBundle(),
            new JMS\SerializerBundle\JMSSerializerBundle($this),
            new JMS\TranslationBundle\JMSTranslationBundle(),
            new JMS\I18nRoutingBundle\JMSI18nRoutingBundle(),
            new Knp\Bundle\MenuBundle\KnpMenuBundle(),
            new Liip\ImagineBundle\LiipImagineBundle(),
            new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(),
            new Vipx\BotDetectBundle\VipxBotDetectBundle(),
            new WhiteOctober\PagerfantaBundle\WhiteOctoberPagerfantaBundle(),
            new Knp\Bundle\GaufretteBundle\KnpGaufretteBundle(),
            new Dizda\CloudBackupBundle\DizdaCloudBackupBundle(),
            new Liuggio\ExcelBundle\LiuggioExcelBundle(),
            new AppBundle\AppBundle(),

//            new Sonata\IntlBundle\SonataIntlBundle(),
//            new HWI\Bundle\OAuthBundle\HWIOAuthBundle(),
//            new Intaro\TwigSandboxBundle\IntaroTwigSandboxBundle(),
//            new WhiteOctober\TCPDFBundle\WhiteOctoberTCPDFBundle(),
        );

        if (in_array($this->getEnvironment(), array('dev', 'test'))) {
            $bundles[] = new JMS\DebuggingBundle\JMSDebuggingBundle($this);
            $bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
            $bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
            $bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
            $bundles[] = new RaulFraile\Bundle\LadybugBundle\RaulFraileLadybugBundle();
            $bundles[] = new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle();
        }

        return $bundles;
    }

【问题讨论】:

  • 我明白这太多了你能解释一下你为什么写这个吗?期望值是多少?是否有其他用户衡量的共同值?你必须记住dev 环境比prod 环境加载更多的类。
  • 看:blackfire.io
  • 谢谢;我已经安装了 blackfire 但它有点压倒性......每个函数调用都给出了内存使用量,而不是捆绑包。不过,我会尝试用它做一些事情。至于一个共同的价值,我有人告诉他,他会在常规项目中使用 5Mb 的内存使用开始控制器操作

标签: php symfony memory memory-management


【解决方案1】:

你启用了 Symfony 的调试栏吗?您可以检查每个请求的时间并找到使用情况,或者按照@Perroin 的建议尝试 blackfire.io

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-12-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-21
    • 1970-01-01
    • 2010-10-08
    相关资源
    最近更新 更多