{"action":"created","issue":{"url":"https://api.github.com/repos/libgdx/libgdx/issues/3659","labels_url":"https://api.github.com/repos/libgdx/libgdx/issues/3659/labels{/name}","comments_url":"https://api.github.com/repos/libgdx/libgdx/issues/3659/comments","events_url":"https://api.github.com/repos/libgdx/libgdx/issues/3659/events","html_url":"https://github.com/libgdx/libgdx/issues/3659","id":123360431,"number":3659,"title":"Add the ability to clear all pools in Pools","user":{"login":"asherbar","id":6441905,"avatar_url":"https://avatars.githubusercontent.com/u/6441905?v=3","gravatar_id":"","url":"https://api.github.com/users/asherbar","html_url":"https://github.com/asherbar","followers_url":"https://api.github.com/users/asherbar/followers","following_url":"https://api.github.com/users/asherbar/following{/other_user}","gists_url":"https://api.github.com/users/asherbar/gists{/gist_id}","starred_url":"https://api.github.com/users/asherbar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asherbar/subscriptions","organizations_url":"https://api.github.com/users/asherbar/orgs","repos_url":"https://api.github.com/users/asherbar/repos","events_url":"https://api.github.com/users/asherbar/events{/privacy}","received_events_url":"https://api.github.com/users/asherbar/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-12-21T21:16:59Z","updated_at":"2015-12-22T10:15:18Z","closed_at":null,"body":"I think it would be useful to add the ability to clear all pools that are stored internally in [Pools](https://github.com/libgdx/libgdx/blob/fde893cec5448fdd09e778d1c103aac474950873/gdx/src/com/badlogic/gdx/utils/Pools.java) via the `static` variable `typePools`. \r\nThe implementation seems to be rather straightforward: Simply iterate over all the `pools` and call their `clear` method. Something like this: \r\n```java\r\npublic class Pools {\r\n    // ...\r\n    public static void clear() {\r\n        for (ObjectMap.Entry<Class, Pool> entry : typePools)  {\r\n            entry.value.clear();\r\n        }\r\n    }\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/libgdx/libgdx/issues/comments/166574134","html_url":"https://github.com/libgdx/libgdx/issues/3659#issuecomment-166574134","issue_url":"https://api.github.com/repos/libgdx/libgdx/issues/3659","id":166574134,"user":{"login":"asherbar","id":6441905,"avatar_url":"https://avatars.githubusercontent.com/u/6441905?v=3","gravatar_id":"","url":"https://api.github.com/users/asherbar","html_url":"https://github.com/asherbar","followers_url":"https://api.github.com/users/asherbar/followers","following_url":"https://api.github.com/users/asherbar/following{/other_user}","gists_url":"https://api.github.com/users/asherbar/gists{/gist_id}","starred_url":"https://api.github.com/users/asherbar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asherbar/subscriptions","organizations_url":"https://api.github.com/users/asherbar/orgs","repos_url":"https://api.github.com/users/asherbar/repos","events_url":"https://api.github.com/users/asherbar/events{/privacy}","received_events_url":"https://api.github.com/users/asherbar/received_events","type":"User","site_admin":false},"created_at":"2015-12-22T10:15:18Z","updated_at":"2015-12-22T10:15:18Z","body":"Consider the following use case:\r\nOn Android, due to the App's lifecycle, `static` references are kept alive when the App is hidden. So say we use `Pools` to obtain objects which reference a [Disposable](https://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/utils/Disposable.html) resource. This means that indirectly, these resources are statically referenced, because they are kept inside the `static` variable `typePools`.\r\n\r\nIt is considered (or so I understand) good practice to dispose resources in [ApplicationListener's](https://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/ApplicationListener.html) `dispose`. So if I do that, this means that after returning to the game, i.e., after `disposed` has been called, recycled objects that were kept alive due to the `static` referencing, are now referencing `disposed` resources. When I obtain these objects from `Pools`, I get unexpected behaviour.\r\n\r\nWith the above request, this problem can be easily be solved by clearing all pools in `Pools`."}}