{"action":"created","issue":{"url":"https://api.github.com/repos/php-pm/php-pm/issues/382","repository_url":"https://api.github.com/repos/php-pm/php-pm","labels_url":"https://api.github.com/repos/php-pm/php-pm/issues/382/labels{/name}","comments_url":"https://api.github.com/repos/php-pm/php-pm/issues/382/comments","events_url":"https://api.github.com/repos/php-pm/php-pm/issues/382/events","html_url":"https://github.com/php-pm/php-pm/issues/382","id":326517869,"node_id":"MDU6SXNzdWUzMjY1MTc4Njk=","number":382,"title":"Memory Leaks","user":{"login":"aftabnaveed","id":58515,"node_id":"MDQ6VXNlcjU4NTE1","avatar_url":"https://avatars2.githubusercontent.com/u/58515?v=4","gravatar_id":"","url":"https://api.github.com/users/aftabnaveed","html_url":"https://github.com/aftabnaveed","followers_url":"https://api.github.com/users/aftabnaveed/followers","following_url":"https://api.github.com/users/aftabnaveed/following{/other_user}","gists_url":"https://api.github.com/users/aftabnaveed/gists{/gist_id}","starred_url":"https://api.github.com/users/aftabnaveed/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aftabnaveed/subscriptions","organizations_url":"https://api.github.com/users/aftabnaveed/orgs","repos_url":"https://api.github.com/users/aftabnaveed/repos","events_url":"https://api.github.com/users/aftabnaveed/events{/privacy}","received_events_url":"https://api.github.com/users/aftabnaveed/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":18,"created_at":"2018-05-25T13:10:24Z","updated_at":"2018-05-30T20:04:19Z","closed_at":null,"author_association":"NONE","body":"I already submitted the ticket here https://github.com/php-pm/php-pm-httpkernel/issues/106 but I am not sure if that was the right place. I apologise for duplicating it. Feel free to delete this one if it does not belong to this package. \r\n\r\nI have setup new Laravel application without any additional packages or service providers it seems like to be leaking memory on each request. I collected the below objects memory table using php meminfo extension. Every time new request is served array and string bytes almost doubles and constantly increasing. \r\n\r\n**Memory Leaks:** \r\n\r\n```\r\n                                                                                                                      │ime (ms)\r\n--- Worker 5501 stderr ---                                                                                             │  50%     24\r\n11546560                                                                                                               │  66%     34\r\n[24/May/2018:16:38:45 +0000] 172.19.0.9 - - \"GET /catalog/product/view/id/34072 HTTP/1.0\" 200 347109 \"-\"               │  75%     50\r\n13175728                                                                                                               │  80%   1380\r\n[24/May/2018:16:39:17 +0000] 172.19.0.9 - - \"GET /catalog/product/view/id/34072 HTTP/1.0\" 200 346935 \"-\"               │  90%   2856\r\n14878304                                                                                                               │  95%  11978\r\n[24/May/2018:16:42:07 +0000] 172.19.0.9 - - \"GET /catalog/product/view/id/34072 HTTP/1.0\" 200 346911 \"-\"               │  98%  17847\r\n16796656                                                                                                               │  99%  22491\r\n[24/May/2018:16:42:37 +0000] 172.19.0.9 - - \"GET /catalog/product/view/id/34072 HTTP/1.0\" 200 346889 \"-\"               │ 100%  30584 (longest request)\r\n```\r\n\r\nWith each request it is adding around 2MB of memory and not releasing it. I generated the meminfo and it is reporting all well, here is the summary: \r\n\r\n```\r\n+---------+-----------------+-----------------------------+\r\n| Type    | Instances Count | Cumulated Self Size (bytes) |\r\n+---------+-----------------+-----------------------------+\r\n| string  | 160             | 5788                        |\r\n| boolean | 44              | 704                         |\r\n| array   | 9               | 648                         |\r\n| integer | 1               | 16                          |\r\n| float   | 1               | 16                          |\r\n+---------+-----------------+-----------------------------+\r\n```\r\nI dumped the above summary inside PHPPM\\Bootstrap\\Laravel@postHandle method\r\n`meminfo_dump(fopen('/tmp/my_dump_file.json', 'w'));`\r\nI do not see any objects listed there which sounds strange to me unless I am misinterpretting it :( \r\n\r\n**Some more Logs**\r\nOk I am able to fix the meminfo dump for my objects and here is the result for 2 requests. \r\n\r\n**First/Initial Request:**\r\n```\r\n+------------------------------------------------------------+-----------------+-----------------------------+\r\n| Type                                                       | Instances Count | Cumulated Self Size (bytes) |\r\n+------------------------------------------------------------+-----------------+-----------------------------+\r\n| array                                                      | 1444            | 103968                      |\r\n| string                                                     | 1222            | 127053                      |\r\n| boolean                                                    | 328             | 5248                        |\r\n| null                                                       | 160             | 2560                        |\r\n| Closure                                                    | 118             | 8496                        |\r\n| integer                                                    | 105             | 1680                        |\r\n| Illuminate\\Foundation\\Application                          | 51              | 3672                        |\r\n| float                                                      | 34              | 544                         |\r\n| unknown                                                    | 31              | 496                         |\r\n| resource                                                   | 18              | 288                         |\r\n| React\\Socket\\Connection                                    | 10              | 720                         |\r\n| React\\Stream\\DuplexResourceStream                          | 10              | 720                         |\r\n| React\\EventLoop\\StreamSelectLoop                           | 9               | 648                         |\r\n| Illuminate\\Routing\\Router                                  | 9               | 648                         |\r\n| Illuminate\\Http\\Request                                    | 8               | 576                         |\r\n| Symfony\\Component\\VarDumper\\Dumper\\CliDumper               | 8               | 576                         |\r\n| Illuminate\\Events\\Dispatcher                               | 8               | 576                         |\r\n| React\\Http\\Io\\MiddlewareRunner                             | 7               | 504                         |\r\n| Illuminate\\Routing\\Route                                   | 7               | 504                         |\r\n| DebugBar\\DataFormatter\\DataFormatter                       | 6               | 432                         |\r\n| Illuminate\\Session\\SessionManager                          | 6               | 432                         |\r\n| PHPPM\\ProcessSlave                                         | 6               | 432                         |\r\n| React\\Http\\Io\\HttpBodyStream                               | 6               | 432                         |\r\n| React\\Http\\Io\\ServerRequest                                | 6               | 432                         |\r\n| Illuminate\\Filesystem\\Filesystem                           | 6               | 432                         |\r\n| React\\Http\\Io\\CloseProtectionStream                        | 5               | 360                         |\r\n| React\\Http\\StreamingServer                                 | 4               | 288                         |\r\n| Illuminate\\Session\\Store                                   | 4               | 288                         |\r\n| Symfony\\Component\\HttpFoundation\\ParameterBag              | 4               | 288                         |\r\n| PHPPM\\Bootstraps\\Laravel                                   | 4               | 288                         |\r\n| Symfony\\Component\\VarDumper\\Cloner\\VarCloner               | 4               | 288                         |\r\n| Illuminate\\Http\\Response                                   | 3               | 216                         |\r\n| RingCentral\\Psr7\\Uri                                       | 3               | 216                         |\r\n| Barryvdh\\Debugbar\\LaravelDebugbar                          | 3               | 216                         |\r\n| Illuminate\\Hashing\\HashManager                             | 3               | 216                         |\r\n| App\\Http\\Kernel                                            | 3               | 216                         |\r\n| Illuminate\\Auth\\AuthManager                                | 3               | 216                         |\r\n| RingCentral\\Psr7\\BufferStream                              | 3               | 216                         |\r\n| Illuminate\\Auth\\AuthServiceProvider                        | 3               | 216                         |\r\n| Illuminate\\Foundation\\Providers\\FormRequestServiceProvider | 3               | 216                         |\r\n| Illuminate\\Routing\\RouteCollection                         | 3               | 216                         |\r\n| Illuminate\\Database\\Connectors\\ConnectionFactory           | 3               | 216                         |\r\n| Barryvdh\\Debugbar\\ServiceProvider                          | 2               | 144                         |\r\n| Illuminate\\Queue\\QueueManager                              | 2               | 144                         |\r\n| Illuminate\\Queue\\QueueServiceProvider                      | 2               | 144                         |\r\n| Illuminate\\Cookie\\CookieJar                                | 2               | 144                         |\r\n| Illuminate\\Auth\\EloquentUserProvider                       | 2               | 144                         |\r\n| Barryvdh\\Debugbar\\SymfonyHttpDriver                        | 2               | 144                         |\r\n| Illuminate\\Cookie\\CookieServiceProvider                    | 2               | 144                         |\r\n[0] 0:bashM 1:docker- 2:[tmux]*                                                                                      \r\n```\r\n\r\n\r\n**Second Run/Request:**\r\n\r\n````\r\n+------------------------------------------------------------+-----------------+-----------------------------+\r\n| Type                                                       | Instances Count | Cumulated Self Size (bytes) |\r\n+------------------------------------------------------------+-----------------+-----------------------------+\r\n| array                                                      | 2131            | 153432                      |\r\n| string                                                     | 1387            | 208403                      |\r\n| boolean                                                    | 382             | 6112                        |\r\n| null                                                       | 205             | 3280                        |\r\n| integer                                                    | 149             | 2384                        |\r\n| Closure                                                    | 137             | 9864                        |\r\n| float                                                      | 62              | 992                         |\r\n| Illuminate\\Foundation\\Application                          | 59              | 4248                        |\r\n| unknown                                                    | 33              | 528                         |\r\n| Illuminate\\Routing\\Route                                   | 32              | 2304                        |\r\n| resource                                                   | 23              | 368                         |\r\n| React\\Http\\Io\\ServerRequest                                | 18              | 1296                        |\r\n| Symfony\\Component\\VarDumper\\Dumper\\CliDumper               | 14              | 1008                        |\r\n| Illuminate\\Routing\\Router                                  | 13              | 936                         |\r\n| DebugBar\\DataFormatter\\DataFormatter                       | 12              | 864                         |\r\n| React\\Stream\\DuplexResourceStream                          | 10              | 720                         |\r\n| React\\EventLoop\\StreamSelectLoop                           | 10              | 720                         |\r\n| Illuminate\\Http\\Request                                    | 9               | 648                         |\r\n| Illuminate\\Session\\SessionManager                          | 9               | 648                         |\r\n| Illuminate\\Events\\Dispatcher                               | 9               | 648                         |\r\n| Illuminate\\Filesystem\\Filesystem                           | 9               | 648                         |\r\n| React\\Http\\Io\\MiddlewareRunner                             | 9               | 648                         |\r\n| React\\Socket\\Connection                                    | 8               | 576                         |\r\n| Symfony\\Component\\HttpFoundation\\ParameterBag              | 8               | 576                         |\r\n| Symfony\\Component\\VarDumper\\Cloner\\VarCloner               | 7               | 504                         |\r\n| PHPPM\\ProcessSlave                                         | 6               | 432                         |\r\n| Illuminate\\Session\\Store                                   | 6               | 432                         |\r\n| React\\Http\\Io\\HttpBodyStream                               | 6               | 432                         |\r\n| Barryvdh\\Debugbar\\LaravelDebugbar                          | 5               | 360                         |\r\n| Illuminate\\Http\\Response                                   | 5               | 360                         |\r\n| React\\Http\\Io\\CloseProtectionStream                        | 5               | 360                         |\r\n| Barryvdh\\Debugbar\\DataCollector\\GateCollector              | 4               | 288                         |\r\n| Barryvdh\\Debugbar\\DataFormatter\\SimpleFormatter            | 4               | 288                         |\r\n| RingCentral\\Psr7\\Uri                                       | 4               | 288                         |\r\n| Illuminate\\Auth\\AuthServiceProvider                        | 4               | 288                         |\r\n| Symfony\\Component\\HttpFoundation\\Cookie                    | 4               | 288                         |\r\n| RingCentral\\Psr7\\BufferStream                              | 4               | 288                         |\r\n| DebugBar\\DataFormatter\\DebugBarVarDumper                   | 4               | 288                         |\r\n| Swift_Plugins_MessageLogger                                | 4               | 288                         |\r\n| React\\EventLoop\\Timer\\Timer                                | 3               | 216                         |\r\n| Illuminate\\Auth\\AuthManager                                | 3               | 216                         |\r\n| Illuminate\\Hashing\\HashManager                             | 3               | 216                         |\r\n| Barryvdh\\Debugbar\\SymfonyHttpDriver                        | 3               | 216                         |\r\n| Illuminate\\Cookie\\CookieServiceProvider                    | 3               | 216                         |\r\n````\r\nI see the instances count for some of the objects in 2nd request has increased which means the previous objects were not cleared properly. \r\n\r\nBTW This is the PHP extension I used to get memory info of my objects:\r\nhttps://github.com/mathieuk/php-meminfo/tree/bugfix/use_correct_symbol_table_php71"},"comment":{"url":"https://api.github.com/repos/php-pm/php-pm/issues/comments/393299414","html_url":"https://github.com/php-pm/php-pm/issues/382#issuecomment-393299414","issue_url":"https://api.github.com/repos/php-pm/php-pm/issues/382","id":393299414,"node_id":"MDEyOklzc3VlQ29tbWVudDM5MzI5OTQxNA==","user":{"login":"andig","id":184815,"node_id":"MDQ6VXNlcjE4NDgxNQ==","avatar_url":"https://avatars1.githubusercontent.com/u/184815?v=4","gravatar_id":"","url":"https://api.github.com/users/andig","html_url":"https://github.com/andig","followers_url":"https://api.github.com/users/andig/followers","following_url":"https://api.github.com/users/andig/following{/other_user}","gists_url":"https://api.github.com/users/andig/gists{/gist_id}","starred_url":"https://api.github.com/users/andig/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andig/subscriptions","organizations_url":"https://api.github.com/users/andig/orgs","repos_url":"https://api.github.com/users/andig/repos","events_url":"https://api.github.com/users/andig/events{/privacy}","received_events_url":"https://api.github.com/users/andig/received_events","type":"User","site_admin":false},"created_at":"2018-05-30T20:04:18Z","updated_at":"2018-05-30T20:04:18Z","author_association":"CONTRIBUTOR","body":"There should imho only be 1 ProcessSlave. Looking at your ab output above, most requests are failing, too. Also- you have 2 workera and hit it with 10 concurrent requests- how should that work? Could you retry ab with 2 concurrent requests and also enable ppm debug and show the console output?"}}
{"actor":{"display_login":"andig"}}