{"action":"opened","issue":{"url":"https://api.github.com/repos/dahlia/wand/issues/254","labels_url":"https://api.github.com/repos/dahlia/wand/issues/254/labels{/name}","comments_url":"https://api.github.com/repos/dahlia/wand/issues/254/comments","events_url":"https://api.github.com/repos/dahlia/wand/issues/254/events","html_url":"https://github.com/dahlia/wand/issues/254","id":97163176,"number":254,"title":"Image.sequence produces memory leaks","user":{"login":"mbarchein","id":1932249,"avatar_url":"https://avatars.githubusercontent.com/u/1932249?v=3","gravatar_id":"","url":"https://api.github.com/users/mbarchein","html_url":"https://github.com/mbarchein","followers_url":"https://api.github.com/users/mbarchein/followers","following_url":"https://api.github.com/users/mbarchein/following{/other_user}","gists_url":"https://api.github.com/users/mbarchein/gists{/gist_id}","starred_url":"https://api.github.com/users/mbarchein/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mbarchein/subscriptions","organizations_url":"https://api.github.com/users/mbarchein/orgs","repos_url":"https://api.github.com/users/mbarchein/repos","events_url":"https://api.github.com/users/mbarchein/events{/privacy}","received_events_url":"https://api.github.com/users/mbarchein/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-07-24T22:47:30Z","updated_at":"2015-07-24T22:47:30Z","closed_at":null,"body":"In my environment (Wand 0.4.0), I have observed that using sequences produces big memory leaks. This test code shows the problem:\r\n\r\n```python\r\nfrom wand.image import Image\r\nimport gc\r\nimport resource\r\n\r\ndef memory_use_kb():\r\n    return resource.getrusage(resource.RUSAGE_SELF).ru_maxrss\r\n\r\ndef f():\r\n    baseimg = Image()\r\n    img = Image(width=3000, height=15000, resolution=600, format=\"png\")\r\n    baseimg.sequence.append(img)\r\n    img.save(filename=\"test.pdf\")\r\n    img.destroy()\r\n\r\nfor x in xrange(0, 10):\r\n    print memory_use_kb()\r\n    f()\r\n\r\ngc.collect()\r\nprint gc.garbage\r\n```\r\n\r\nThe output is:\r\n\r\n```\r\n13336\r\n762524\r\n1117504\r\n1469076\r\n1820736\r\n2172336\r\n2524164\r\n2875776\r\n3227364\r\n3578856\r\n```\r\n\r\nThe leak is really annoing in a Django app, as it exhausts all the server memory in a few rounds."}}