{"comment":{"created_at":"2011-10-10T20:08:18Z","body":"Have you thought to disable the logger?","updated_at":"2011-10-10T20:08:18Z","url":"https://api.github.com/repos/symfony/symfony/issues/comments/2351594","id":2351594,"user":{"avatar_url":"https://secure.gravatar.com/avatar/34c17828d5b464aaa1b382b34e9ab1f8?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","url":"https://api.github.com/users/jalliot","id":387904,"login":"jalliot"}},"action":"created","issue":{"number":2376,"created_at":"2011-10-10T20:00:34Z","pull_request":{"diff_url":null,"patch_url":null,"html_url":null},"body":"Hi everybody,\r\n\r\nSince I didn't get any answer to my post in Symfony Dev Group, Hugo H told me to post here the following memory leak problem.\r\n\r\nI have made **a very simple batch command that you can find at the end**  so you can test and check if I missed something or not.\r\n\r\n**What does this batch ?**\r\nIt takes a very simple object (created only for testing purpose) :\r\n\r\n```php\r\nclass TestDomainObject implements DomainObjectInterface\r\n{\r\n\tprotected $id = 0;\r\n\t\r\n\tpublic function __construct(){\r\n\t\t\r\n\t}\r\n\r\n\tpublic function setId($id){\r\n\t\t$this->id = $id;\r\n\t}\r\n\tpublic function getObjectIdentifier() {\r\n\t\treturn strtoupper(\"TESTDO_\".$this->id);\r\n\t}\r\n\t\r\n\tpublic function getId() {\r\n\t\treturn $this->id;\r\n\t}\r\n}\r\n```\r\n\r\nThen make a simple ACL creation with one ACE :\r\n\r\n```php\r\nprotected function testUpdateACL($id)\r\n{\r\n    \t$this->testDomainObject->setId($id);\r\n    \t$objectIdentity = ObjectIdentity::fromDomainObject($this->testDomainObject);\r\n    \t$acl = $this->aclProvider->createAcl($objectIdentity);\r\n\t$adminIdentity = new RoleSecurityIdentity(\"ROLE_ADMIN\");\r\n        $acl->insertObjectAce($adminIdentity, MaskBuilder::MASK_VIEW);\r\n        $this->aclProvider->updateAcl($acl);\r\n}\r\n```\r\n\r\nAnd Iterate  30000 times on this update :\r\n\r\n```php\r\nfor($i=0; $i<30000; $i++) {\r\n\t$this->testUpdateACL($i);\r\n\tif (($i % 2000) == 0) {\r\n\t\t$output->write(\"Iteration =\".$i.\" Memory = \".memory_get_usage().PHP_EOL);\r\n\t}\r\n}\r\n```\r\n\r\nThen just run the test taking care of no-debug option in env prod :\r\n\r\n```php\r\napp/console --no-debug --env=\"prod\" acl:leak\r\n```\r\n\r\n**Result :**\r\nIteration =0 Memory = 30336888\r\nIteration =2000 Memory = 41741288\r\nIteration =4000 Memory = 57838048\r\nIteration =6000 Memory = 73056744\r\nIteration =8000 Memory = 89967144\r\nIteration =10000 Memory = 105108416\r\nIteration =12000 Memory = 119921520\r\nIteration =14000 Memory = 134733504\r\nIteration =16000 Memory = 153898744\r\nIteration =18000 Memory = 169364552\r\nIteration =20000 Memory = 184178000\r\nIteration =22000 Memory = 198991480\r\nIteration =24000 Memory = 213802848\r\nIteration =26000 Memory = 228772712\r\nIteration =28000 Memory = 243585680\r\n\r\nDid I missed something or is it an ACL problem with use of DBAL ? \r\nThks\r\nY\r\n\r\n## LeakAclCommand.php\r\n\r\n```php\r\n<?php\r\nnamespace FSC\\CoreBundle\\Command;\r\nuse Symfony\\Component\\Security\\Acl\\Permission\\MaskBuilder;\r\nuse Symfony\\Component\\Security\\Acl\\Domain\\ObjectIdentity;\r\nuse Symfony\\Component\\Security\\Acl\\Domain\\RoleSecurityIdentity;\r\n\r\nuse Symfony\\Bundle\\FrameworkBundle\\Command\\ContainerAwareCommand;\r\nuse Symfony\\Component\\Console\\Input\\InputInterface;\r\nuse Symfony\\Component\\Console\\Input\\InputOption;\r\nuse Symfony\\Component\\Console\\Output\\OutputInterface;\r\n\r\n\r\nclass LeakAclCommand extends ContainerAwareCommand\r\n{\r\n\tprivate $testDomainObject;\r\n\tprivate $aclProvider;\r\n\t\r\n    /**\r\n     * @see Command\r\n     */ \r\n\tprotected function configure()\r\n    {\r\n    \t\r\n        $this->setName('acl:leak')\r\n       \t\t->setDescription(\"Test memory leak on ACL\");\r\n    }\r\n\r\n    /**\r\n     * @see Command\r\n     */\r\n    protected function execute(InputInterface $input, OutputInterface $output)\r\n    {\r\n\t\ttry\r\n\t\t{\r\n\t\t\t$this->aclProvider = $this->getContainer()->get('security.acl.provider');\r\n\t\t\t$this->testDomainObject = new TestDomainObject();\r\n\t\t\tfor($i=0; $i<30000; $i++) {\r\n\t\t\t\t$this->testUpdateACL($i);\r\n\t\t\t\tif (($i % 2000) == 0) {\r\n\t\t\t\t\t$output->write(\"Iteration =\".$i.\" Memory = \".memory_get_usage().PHP_EOL);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\t$output->write('Test Done'. PHP_EOL);\r\n\t\t}\r\n\t\tcatch (\\Exception $e)\r\n\t\t{\r\n\t\t    $output->write(PHP_EOL.'Caught a Exception. (' . $e->getMessage() . ')' . PHP_EOL);\r\n\t\t} \r\n        \r\n    }\r\n    \r\n\tprotected function testUpdateACL($id)\r\n    {\r\n    \t$this->testDomainObject->setId($id);\r\n    \t$objectIdentity = ObjectIdentity::fromDomainObject($this->testDomainObject);\r\n    \t$acl = $this->aclProvider->createAcl($objectIdentity);\r\n\t\t$adminIdentity = new RoleSecurityIdentity(\"ROLE_ADMIN\");\r\n        $acl->insertObjectAce($adminIdentity, MaskBuilder::MASK_VIEW);\r\n        $this->aclProvider->updateAcl($acl);\r\n    }\r\n}\r\n\r\nuse Symfony\\Component\\Security\\Acl\\Model\\DomainObjectInterface;\r\n\r\nclass TestDomainObject implements DomainObjectInterface\r\n{\r\n\tprotected $id = 0;\r\n\t\r\n\tpublic function __construct(){\r\n\t\t\r\n\t}\r\n\r\n\tpublic function setId($id){\r\n\t\t$this->id = $id;\r\n\t}\r\n\tpublic function getObjectIdentifier() {\r\n\t\treturn strtoupper(\"TESTDO_\".$this->id);\r\n\t}\r\n\t\r\n\tpublic function getId() {\r\n\t\treturn $this->id;\r\n\t}\r\n}\r\n```","comments":1,"title":"ACL Memory Leak","updated_at":"2011-10-10T20:08:20Z","url":"https://api.github.com/repos/symfony/symfony/issues/2376","id":1867536,"assignee":null,"milestone":null,"closed_at":null,"user":{"avatar_url":"https://secure.gravatar.com/avatar/65ef7e12fc0390d4212e6fc84449f908?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","url":"https://api.github.com/users/KaipiYann","id":821197,"login":"KaipiYann"},"html_url":"https://github.com/symfony/symfony/issues/2376","labels":[],"state":"open"},"legacy":{"issue_id":1867536,"comment_id":2351594}}