{"action":"created","issue":{"url":"https://api.github.com/repos/pimcore/pimcore/issues/216","labels_url":"https://api.github.com/repos/pimcore/pimcore/issues/216/labels{/name}","comments_url":"https://api.github.com/repos/pimcore/pimcore/issues/216/comments","events_url":"https://api.github.com/repos/pimcore/pimcore/issues/216/events","html_url":"https://github.com/pimcore/pimcore/issues/216","id":100357842,"number":216,"title":"Problem with Backend cache growing object size stored.","user":{"login":"Yivan","id":9025839,"avatar_url":"https://avatars.githubusercontent.com/u/9025839?v=3","gravatar_id":"","url":"https://api.github.com/users/Yivan","html_url":"https://github.com/Yivan","followers_url":"https://api.github.com/users/Yivan/followers","following_url":"https://api.github.com/users/Yivan/following{/other_user}","gists_url":"https://api.github.com/users/Yivan/gists{/gist_id}","starred_url":"https://api.github.com/users/Yivan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Yivan/subscriptions","organizations_url":"https://api.github.com/users/Yivan/orgs","repos_url":"https://api.github.com/users/Yivan/repos","events_url":"https://api.github.com/users/Yivan/events{/privacy}","received_events_url":"https://api.github.com/users/Yivan/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2015-08-11T16:55:22Z","updated_at":"2015-08-12T17:39:35Z","closed_at":null,"body":"Following the discussion here : https://www.pimcore.org/board/viewtopic.php?f=7&t=1386&p=9480\r\n\r\nIt seems that the stored cached object (called back in getById) take more size than the object itself. Maybe some information is appended in the time making it growing... but problem is after some days, getList method can use all memory if many object are fetched from the cache.\r\n\r\nWe got problem with Redis2 cache, but user in the forum reported having same problem with memcache.\r\nI think it is a global cache problem (not depending from the backend cahce method), as the memory problem is object use more and more memory and finally overflow the PHP limit.\r\n\r\nAs other user we only had this problem with the recents Pimcore versions. Maybe something changed.\r\n\r\nBest regards!\r\n\r\n\r\n-------------------------\r\nFact posted by us on the forum at the mentionned thread:\r\n\r\nI got the same problem with Redis as backend cache.\r\n<backend>\r\n<type>\\Pimcore\\Cache\\Backend\\Redis2</type>\r\n<custom>true</custom>\r\n<options>\r\n<server>127.0.0.1</server>\r\n<port>6379</port>\r\n<persistent>1</persistent>\r\n<database>1</database>\r\n<use_lua>1</use_lua>\r\n</options>\r\n</backend>\r\n\r\nSo it doesn't come specificaly from Memcached, but from the global cache mecanism maybe.\r\n\r\nPimcore 3.0.6 (last stable version):\r\nPHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 512 bytes) in .../pimcore/lib/Zend/Cache/Core.php on line 313\r\n\r\nIt works well and after some days we got this error. Flushing the cache make it work again.\r\nOk after further investigation, it seems that the cached object (when you get them with getById) take more memory than if you do not fetch them from the cache.\r\n\r\n-------------------------\r\nAfter more investigation we found:\r\n\r\nIf i keep code fetching from cache i got (memory_get_usage() / memory_get_usage(true) is given)\r\n\r\nIs going to getById object ID: 46 (memory before: 3.47 mb / 3.75 mb)\r\nIs going to getById object ID: 48 (memory before: 36.19 mb / 44.25 mb)\r\nIs going to getById object ID: 50 (memory before: 36.66 mb / 44.25 mb)\r\nIs going to getById object ID: 52 (memory before: 38.32 mb / 44.25 mb)\r\nIs going to getById object ID: 54 (memory before: 38.7 mb / 44.25 mb)\r\nIs going to getById object ID: 56 (memory before: 40.33 mb / 44.25 mb)\r\nIs going to getById object ID: 58 (memory before: 41.08 mb / 44.75 mb)\r\nIs going to getById object ID: 60 (memory before: 41.24 mb / 44.75 mb)\r\nIs going to getById object ID: 94 (memory before: 41.46 mb / 44.75 mb)\r\nIs going to getById object ID: 97 (memory before: 41.75 mb / 44.75 mb)\r\nIs going to getById object ID: 104 (memory before: 42.22 mb / 44.75 mb)\r\nIs going to getById object ID: 105 (memory before: 42.22 mb / 44.75 mb)\r\nIs going to getById object ID: 107 (memory before: 42.22 mb / 44.75 mb)\r\nIs going to getById object ID: 108 (memory before: 42.65 mb / 44.75 mb)\r\nIs going to getById object ID: 109 (memory before: 43.28 mb / 44.75 mb)\r\nIs going to getById object ID: 110 (memory before: 43.45 mb / 44.75 mb)\r\nIs going to getById object ID: 111 (memory before: 43.83 mb / 44.75 mb)\r\nIs going to getById object ID: 112 (memory before: 43.91 mb / 44.75 mb)\r\nIs going to getById object ID: 113 (memory before: 75.75 mb / 83.75 mb)\r\nIs going to getById object ID: 114 (memory before: 76.14 mb / 83.75 mb)\r\nIs going to getById object ID: 115 (memory before: 80.45 mb / 84.75 mb)\r\nIs going to getById object ID: 116 (memory before: 83.59 mb / 84.75 mb)\r\nIs going to getById object ID: 117 (memory before: 83.77 mb / 84.75 mb)\r\nIs going to getById object ID: 118 (memory before: 83.93 mb / 84.75 mb)\r\nIs going to getById object ID: 119 (memory before: 84.04 mb / 84.75 mb)\r\nIs going to getById object ID: 120 (memory before: 84.17 mb / 84.75 mb)\r\nIs going to getById object ID: 121 (memory before: 84.31 mb / 84.75 mb)\r\nIs going to getById object ID: 122 (memory before: 84.46 mb / 85 mb)\r\nIs going to getById object ID: 123 (memory before: 84.66 mb / 85.25 mb)\r\nIs going to getById object ID: 124 (memory before: 84.74 mb / 85.25 mb)\r\nIs going to getById object ID: 126 (memory before: 84.83 mb / 85.25 mb)\r\nIs going to getById object ID: 127 (memory before: 85.06 mb / 85.5 mb)\r\nIs going to getById object ID: 128 (memory before: 85.29 mb / 85.75 mb)\r\nIs going to getById object ID: 129 (memory before: 85.52 mb / 86 mb)\r\nIs going to getById object ID: 130 (memory before: 85.6 mb / 86 mb)\r\nIs going to getById object ID: 131 (memory before: 86.98 mb / 87.75 mb)\r\nIs going to getById object ID: 132 (memory before: 87.08 mb / 87.75 mb)\r\nIs going to getById object ID: 914 (memory before: 87.17 mb / 87.75 mb)\r\nIs going to getById object ID: 936 (memory before: 87.45 mb / 88 mb)\r\n\r\nAnd if i disable cache loading (by directly editing getById method in \\pimcore\\models\\Object\\AbstractObject.php and disable $object = Cache::load($cacheKey) line 238) i got:\r\n\r\nIs going to getById object ID: 46 (memory before: 3.47 mb / 3.75 mb)\r\nIs going to getById object ID: 48 (memory before: 5.49 mb / 5.75 mb)\r\nIs going to getById object ID: 50 (memory before: 5.92 mb / 6.25 mb)\r\nIs going to getById object ID: 52 (memory before: 6.46 mb / 6.75 mb)\r\nIs going to getById object ID: 54 (memory before: 6.8 mb / 7 mb)\r\nIs going to getById object ID: 56 (memory before: 7.22 mb / 7.5 mb)\r\nIs going to getById object ID: 58 (memory before: 7.44 mb / 7.75 mb)\r\nIs going to getById object ID: 60 (memory before: 7.59 mb / 7.75 mb)\r\nIs going to getById object ID: 94 (memory before: 7.79 mb / 8 mb)\r\nIs going to getById object ID: 97 (memory before: 8.18 mb / 8.75 mb)\r\nIs going to getById object ID: 104 (memory before: 8.18 mb / 8.75 mb)\r\nIs going to getById object ID: 105 (memory before: 8.18 mb / 8.75 mb)\r\nIs going to getById object ID: 107 (memory before: 8.18 mb / 8.75 mb)\r\nIs going to getById object ID: 108 (memory before: 8.57 mb / 9 mb)\r\nIs going to getById object ID: 109 (memory before: 8.57 mb / 9 mb)\r\nIs going to getById object ID: 110 (memory before: 8.72 mb / 9.25 mb)\r\nIs going to getById object ID: 111 (memory before: 8.72 mb / 9.25 mb)\r\nIs going to getById object ID: 112 (memory before: 8.8 mb / 9.25 mb)\r\nIs going to getById object ID: 113 (memory before: 8.8 mb / 9.25 mb)\r\nIs going to getById object ID: 114 (memory before: 8.8 mb / 9.25 mb)\r\nIs going to getById object ID: 115 (memory before: 9.03 mb / 9.5 mb)\r\nIs going to getById object ID: 116 (memory before: 9.03 mb / 9.5 mb)\r\nIs going to getById object ID: 117 (memory before: 9.19 mb / 9.75 mb)\r\nIs going to getById object ID: 118 (memory before: 9.34 mb / 9.75 mb)\r\nIs going to getById object ID: 119 (memory before: 9.34 mb / 9.75 mb)\r\nIs going to getById object ID: 120 (memory before: 9.46 mb / 10 mb)\r\nIs going to getById object ID: 121 (memory before: 9.6 mb / 10 mb)\r\nIs going to getById object ID: 122 (memory before: 9.73 mb / 10.25 mb)\r\nIs going to getById object ID: 123 (memory before: 9.92 mb / 10.5 mb)\r\nIs going to getById object ID: 124 (memory before: 9.99 mb / 10.5 mb)\r\nIs going to getById object ID: 126 (memory before: 9.99 mb / 10.5 mb)\r\nIs going to getById object ID: 127 (memory before: 10.2 mb / 10.75 mb)\r\nIs going to getById object ID: 128 (memory before: 10.4 mb / 11 mb)\r\nIs going to getById object ID: 129 (memory before: 10.4 mb / 11 mb)\r\nIs going to getById object ID: 130 (memory before: 10.49 mb / 11 mb)\r\nIs going to getById object ID: 131 (memory before: 10.49 mb / 11 mb)\r\nIs going to getById object ID: 132 (memory before: 10.57 mb / 11 mb)\r\nIs going to getById object ID: 914 (memory before: 10.65 mb / 11.25 mb)\r\nIs going to getById object ID: 936 (memory before: 10.92 mb / 11.5 mb)\r\n\r\nThere is a problem as cached data take many more memory than directly fetching them freshly.\r\nSo actullay i thing it use the 128mb available at the end and Zend_Cache has no more memory to unserialize it in /pimcore/lib/Zend/Cache/Core.php on line 313, making the fatal error.\r\n"},"comment":{"url":"https://api.github.com/repos/pimcore/pimcore/issues/comments/130386183","html_url":"https://github.com/pimcore/pimcore/issues/216#issuecomment-130386183","issue_url":"https://api.github.com/repos/pimcore/pimcore/issues/216","id":130386183,"user":{"login":"brusch","id":142037,"avatar_url":"https://avatars.githubusercontent.com/u/142037?v=3","gravatar_id":"","url":"https://api.github.com/users/brusch","html_url":"https://github.com/brusch","followers_url":"https://api.github.com/users/brusch/followers","following_url":"https://api.github.com/users/brusch/following{/other_user}","gists_url":"https://api.github.com/users/brusch/gists{/gist_id}","starred_url":"https://api.github.com/users/brusch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brusch/subscriptions","organizations_url":"https://api.github.com/users/brusch/orgs","repos_url":"https://api.github.com/users/brusch/repos","events_url":"https://api.github.com/users/brusch/events{/privacy}","received_events_url":"https://api.github.com/users/brusch/received_events","type":"User","site_admin":false},"created_at":"2015-08-12T17:39:35Z","updated_at":"2015-08-12T17:39:35Z","body":"There was actually also a fix for objects (image & image advanced). "}}