{"action":"created","issue":{"url":"https://api.github.com/repos/sympy/sympy/issues/11819","repository_url":"https://api.github.com/repos/sympy/sympy","labels_url":"https://api.github.com/repos/sympy/sympy/issues/11819/labels{/name}","comments_url":"https://api.github.com/repos/sympy/sympy/issues/11819/comments","events_url":"https://api.github.com/repos/sympy/sympy/issues/11819/events","html_url":"https://github.com/sympy/sympy/issues/11819","id":187619911,"number":11819,"title":"SymPy's cache doesn't free objects at the end","user":{"login":"isuruf","id":5234427,"avatar_url":"https://avatars.githubusercontent.com/u/5234427?v=3","gravatar_id":"","url":"https://api.github.com/users/isuruf","html_url":"https://github.com/isuruf","followers_url":"https://api.github.com/users/isuruf/followers","following_url":"https://api.github.com/users/isuruf/following{/other_user}","gists_url":"https://api.github.com/users/isuruf/gists{/gist_id}","starred_url":"https://api.github.com/users/isuruf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/isuruf/subscriptions","organizations_url":"https://api.github.com/users/isuruf/orgs","repos_url":"https://api.github.com/users/isuruf/repos","events_url":"https://api.github.com/users/isuruf/events{/privacy}","received_events_url":"https://api.github.com/users/isuruf/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":7,"created_at":"2016-11-07T03:51:19Z","updated_at":"2016-11-08T04:13:47Z","closed_at":null,"body":"This can be observed when running symengine under debug mode.\r\n\r\nWhen a sympy function that is decorated with `cacheit` is called with a symengine object, symengine object is converted to a sympy object and the function works correctly.\r\nThese symengine objects are not freed at the end though. (Seen from symengine's debug mode object pool, which gives a warning that these objects are not freed).\r\n\r\nWhen SYMPY_USE_CACHE=no is set, no such leaks occur."},"comment":{"url":"https://api.github.com/repos/sympy/sympy/issues/comments/259041218","html_url":"https://github.com/sympy/sympy/issues/11819#issuecomment-259041218","issue_url":"https://api.github.com/repos/sympy/sympy/issues/11819","id":259041218,"user":{"login":"isuruf","id":5234427,"avatar_url":"https://avatars.githubusercontent.com/u/5234427?v=3","gravatar_id":"","url":"https://api.github.com/users/isuruf","html_url":"https://github.com/isuruf","followers_url":"https://api.github.com/users/isuruf/followers","following_url":"https://api.github.com/users/isuruf/following{/other_user}","gists_url":"https://api.github.com/users/isuruf/gists{/gist_id}","starred_url":"https://api.github.com/users/isuruf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/isuruf/subscriptions","organizations_url":"https://api.github.com/users/isuruf/orgs","repos_url":"https://api.github.com/users/isuruf/repos","events_url":"https://api.github.com/users/isuruf/events{/privacy}","received_events_url":"https://api.github.com/users/isuruf/received_events","type":"User","site_admin":false},"created_at":"2016-11-08T04:13:47Z","updated_at":"2016-11-08T04:13:47Z","body":"This is a gc issue. I'm not familiar with how Python's gc works to give you a reason for it\r\nFollowing patch fixes it. \r\n\r\n```diff\r\ndiff --git a/sympy/core/cache.py b/sympy/core/cache.py\r\nindex b6c64c1..680a443 100644\r\n--- a/sympy/core/cache.py\r\n+++ b/sympy/core/cache.py\r\n@@ -105,8 +105,8 @@ def wrapper(*args, **kwargs):\r\n             # assign to wrapper.__wrapped__.\r\n             update_wrapper(wrapper, func)\r\n             wrapper.__wrapped__ = cfunc.__wrapped__\r\n-\r\n-            CACHE.append(wrapper)\r\n+            import weakref\r\n+            CACHE.append(weakref.ref(wrapper))\r\n             return wrapper\r\n \r\n         return func_wrapper\r\n@@ -136,7 +136,8 @@ def __cacheit(maxsize):\r\n         def func_wrapper(func):\r\n \r\n             cfunc = fastcache.clru_cache(maxsize, typed=True, unhashable='ignore')(func)\r\n-            CACHE.append(cfunc)\r\n+            import weakref\r\n+            CACHE.append(weakref.ref(cfunc))\r\n             return cfunc\r\n \r\n         return func_wrapper\r\n```"}}
{"actor":{"display_login":"isuruf"}}