{"action":"closed","issue":{"url":"https://api.github.com/repos/OpenIDC/pyoidc/issues/498","repository_url":"https://api.github.com/repos/OpenIDC/pyoidc","labels_url":"https://api.github.com/repos/OpenIDC/pyoidc/issues/498/labels{/name}","comments_url":"https://api.github.com/repos/OpenIDC/pyoidc/issues/498/comments","events_url":"https://api.github.com/repos/OpenIDC/pyoidc/issues/498/events","html_url":"https://github.com/OpenIDC/pyoidc/issues/498","id":298956711,"number":498,"title":"Memory leaking based on storing all state tokens including very old ones","user":{"login":"Seraphirn","id":2100006,"avatar_url":"https://avatars0.githubusercontent.com/u/2100006?v=4","gravatar_id":"","url":"https://api.github.com/users/Seraphirn","html_url":"https://github.com/Seraphirn","followers_url":"https://api.github.com/users/Seraphirn/followers","following_url":"https://api.github.com/users/Seraphirn/following{/other_user}","gists_url":"https://api.github.com/users/Seraphirn/gists{/gist_id}","starred_url":"https://api.github.com/users/Seraphirn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Seraphirn/subscriptions","organizations_url":"https://api.github.com/users/Seraphirn/orgs","repos_url":"https://api.github.com/users/Seraphirn/repos","events_url":"https://api.github.com/users/Seraphirn/events{/privacy}","received_events_url":"https://api.github.com/users/Seraphirn/received_events","type":"User","site_admin":false},"labels":[{"id":544715720,"url":"https://api.github.com/repos/OpenIDC/pyoidc/labels/enhancement","name":"enhancement","color":"fbca04","default":true}],"state":"closed","locked":false,"assignee":{"login":"tpazderka","id":7734753,"avatar_url":"https://avatars3.githubusercontent.com/u/7734753?v=4","gravatar_id":"","url":"https://api.github.com/users/tpazderka","html_url":"https://github.com/tpazderka","followers_url":"https://api.github.com/users/tpazderka/followers","following_url":"https://api.github.com/users/tpazderka/following{/other_user}","gists_url":"https://api.github.com/users/tpazderka/gists{/gist_id}","starred_url":"https://api.github.com/users/tpazderka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tpazderka/subscriptions","organizations_url":"https://api.github.com/users/tpazderka/orgs","repos_url":"https://api.github.com/users/tpazderka/repos","events_url":"https://api.github.com/users/tpazderka/events{/privacy}","received_events_url":"https://api.github.com/users/tpazderka/received_events","type":"User","site_admin":false},"assignees":[{"login":"tpazderka","id":7734753,"avatar_url":"https://avatars3.githubusercontent.com/u/7734753?v=4","gravatar_id":"","url":"https://api.github.com/users/tpazderka","html_url":"https://github.com/tpazderka","followers_url":"https://api.github.com/users/tpazderka/followers","following_url":"https://api.github.com/users/tpazderka/following{/other_user}","gists_url":"https://api.github.com/users/tpazderka/gists{/gist_id}","starred_url":"https://api.github.com/users/tpazderka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tpazderka/subscriptions","organizations_url":"https://api.github.com/users/tpazderka/orgs","repos_url":"https://api.github.com/users/tpazderka/repos","events_url":"https://api.github.com/users/tpazderka/events{/privacy}","received_events_url":"https://api.github.com/users/tpazderka/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/OpenIDC/pyoidc/milestones/6","html_url":"https://github.com/OpenIDC/pyoidc/milestone/6","labels_url":"https://api.github.com/repos/OpenIDC/pyoidc/milestones/6/labels","id":3129274,"number":6,"title":"0.14.0","description":null,"creator":{"login":"tpazderka","id":7734753,"avatar_url":"https://avatars3.githubusercontent.com/u/7734753?v=4","gravatar_id":"","url":"https://api.github.com/users/tpazderka","html_url":"https://github.com/tpazderka","followers_url":"https://api.github.com/users/tpazderka/followers","following_url":"https://api.github.com/users/tpazderka/following{/other_user}","gists_url":"https://api.github.com/users/tpazderka/gists{/gist_id}","starred_url":"https://api.github.com/users/tpazderka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tpazderka/subscriptions","organizations_url":"https://api.github.com/users/tpazderka/orgs","repos_url":"https://api.github.com/users/tpazderka/repos","events_url":"https://api.github.com/users/tpazderka/events{/privacy}","received_events_url":"https://api.github.com/users/tpazderka/received_events","type":"User","site_admin":false},"open_issues":0,"closed_issues":14,"state":"open","created_at":"2018-02-20T10:20:13Z","updated_at":"2018-05-02T08:33:07Z","due_on":null,"closed_at":null},"comments":1,"created_at":"2018-02-21T12:46:45Z","updated_at":"2018-05-02T08:33:07Z","closed_at":"2018-05-02T08:33:07Z","author_association":"NONE","body":"I use this lib and face this problem:\r\n - On every oic_client do_access_token_refresh method call my app leaks about 8-9KB.\r\n\r\nI started to figure out the problem and found this:\r\n in oic Client class all tokens stored in grants dictionaries. All tokens is stored - outdated or not. So when I request new access and refresh token by refresh request, old one will stay there.\r\n\r\nSo in my app I wrote this code, to delete outdated tokens (based on refresh_token expired)\r\n\r\n```        \r\n        now = time.time()\r\n        # Preventing oic client from memory leaking\r\n        oic_token_to_delete = [\r\n            (state, token)\r\n            for (state, grant) in self._oic_client.grant.items()\r\n            for token in grant.tokens\r\n            if now > token.id_token['iat'] + token.refresh_expires_in\r\n        ]\r\n        if oic_token_to_delete:\r\n            LOG.debug('Outdated OIC tokens deleted %s'\r\n                      % len(oic_token_to_delete))\r\n            for state, token in oic_token_to_delete:\r\n                self._oic_client.grant[state].tokens.remove(token)\r\n```\r\n\r\nCan you handle this? For example delete old tokens on refresh response, or create public method that clears old outdated tokens and lib users will call it by schedule?\r\n\r\nFound leaking by pympler lib\r\n\r\n```\r\n---- SUMMARY ------------------------------------------------------------------\r\nUSR2 2018-02-21 15:17:53.536290          active      0     B      average   pct\r\n  Client                                      1     48.37 KB     48.37 KB    0%\r\n-------------------------------------------------------------------------------\r\n\r\n...\r\ntoken refreshed ones\r\n...\r\n\r\n---- SUMMARY ------------------------------------------------------------------\r\nUSR2 2018-02-21 15:17:53.536290          active      0     B      average   pct\r\n  Client                                      1     48.37 KB     48.37 KB    0%\r\nUSR2 2018-02-21 15:38:21.922070          active      0     B      average   pct\r\n  Client                                      1     56.61 KB     56.61 KB    0%\r\n-------------------------------------------------------------------------------\r\n```\r\n"}}
{"actor":{"display_login":"tpazderka"}}