{"action":"created","issue":{"url":"https://api.github.com/repos/thumbor/thumbor/issues/753","repository_url":"https://api.github.com/repos/thumbor/thumbor","labels_url":"https://api.github.com/repos/thumbor/thumbor/issues/753/labels{/name}","comments_url":"https://api.github.com/repos/thumbor/thumbor/issues/753/comments","events_url":"https://api.github.com/repos/thumbor/thumbor/issues/753/events","html_url":"https://github.com/thumbor/thumbor/issues/753","id":159917271,"number":753,"title":"Memory Usage Explosion","user":{"login":"kuntoaji","id":170858,"avatar_url":"https://avatars1.githubusercontent.com/u/170858?v=4","gravatar_id":"","url":"https://api.github.com/users/kuntoaji","html_url":"https://github.com/kuntoaji","followers_url":"https://api.github.com/users/kuntoaji/followers","following_url":"https://api.github.com/users/kuntoaji/following{/other_user}","gists_url":"https://api.github.com/users/kuntoaji/gists{/gist_id}","starred_url":"https://api.github.com/users/kuntoaji/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kuntoaji/subscriptions","organizations_url":"https://api.github.com/users/kuntoaji/orgs","repos_url":"https://api.github.com/users/kuntoaji/repos","events_url":"https://api.github.com/users/kuntoaji/events{/privacy}","received_events_url":"https://api.github.com/users/kuntoaji/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"SergioJorge","id":813448,"avatar_url":"https://avatars3.githubusercontent.com/u/813448?v=4","gravatar_id":"","url":"https://api.github.com/users/SergioJorge","html_url":"https://github.com/SergioJorge","followers_url":"https://api.github.com/users/SergioJorge/followers","following_url":"https://api.github.com/users/SergioJorge/following{/other_user}","gists_url":"https://api.github.com/users/SergioJorge/gists{/gist_id}","starred_url":"https://api.github.com/users/SergioJorge/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SergioJorge/subscriptions","organizations_url":"https://api.github.com/users/SergioJorge/orgs","repos_url":"https://api.github.com/users/SergioJorge/repos","events_url":"https://api.github.com/users/SergioJorge/events{/privacy}","received_events_url":"https://api.github.com/users/SergioJorge/received_events","type":"User","site_admin":false},"assignees":[{"login":"SergioJorge","id":813448,"avatar_url":"https://avatars3.githubusercontent.com/u/813448?v=4","gravatar_id":"","url":"https://api.github.com/users/SergioJorge","html_url":"https://github.com/SergioJorge","followers_url":"https://api.github.com/users/SergioJorge/followers","following_url":"https://api.github.com/users/SergioJorge/following{/other_user}","gists_url":"https://api.github.com/users/SergioJorge/gists{/gist_id}","starred_url":"https://api.github.com/users/SergioJorge/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SergioJorge/subscriptions","organizations_url":"https://api.github.com/users/SergioJorge/orgs","repos_url":"https://api.github.com/users/SergioJorge/repos","events_url":"https://api.github.com/users/SergioJorge/events{/privacy}","received_events_url":"https://api.github.com/users/SergioJorge/received_events","type":"User","site_admin":false}],"milestone":null,"comments":43,"created_at":"2016-06-13T10:18:24Z","updated_at":"2018-02-05T23:54:57Z","closed_at":null,"author_association":"NONE","body":"We are experiencing memory usage explosion on Ubuntu 14.04.1 LTS with Thumbor v6.0.1 and Pillow 3.2.0. Our memory usage can hit ~97%. Then it will return to ~60% memory usage and after some time it will hit again ~97% memory usage.\n\nAfter some investigation, there is possility that `resize` method in `thumbor/engines/pil.py` is the root cause. If we run `gc.collect()` in `resize` method, our memory usage is never hit 97% again.\n### Thumbor request URL\n\nSample url `http://localhost:7001/unsafe/1920x1080/filename.jpg`\n\nScript to reproduce\n\n``` ruby\n#! /usr/bin/env ruby\n\nrequire 'open-uri'\n\n@total = 0\ncount = 100000\n\n(5000..(5000+count)).each do |i|\n  size = 2000 + rand(2000)\n  wxh = [size, size].join('x')\n  url = \"http://localhost:7001/unsafe/#{wxh}/filename.jpg\"\n  start_time = Time.now\n  open url\n  end_time = Time.now\n  duration = end_time - start_time\n  @total += duration\n  puts \"got: #{url} in #{duration.round(2)}\"\nend\n\nputs \"That took: #{@total.round(2)} seconds\"\nputs \"Average #{(@total / count).round(2)} per image\"\n\n```\n### Expected behaviour\n\nMemory usage should below 90%\n### Actual behaviour\n\nMemory usage hit ~97%\n### Operating system\n\n14.04.1 LTS\nThumbor v6.0.1\nPillow 3.2.0\n### thumbor.conf\n\n```\nMAX_AGE = 31536000\nALLOW_ANIMATED_GIFS = False\nLOADER = 'thumbor.loaders.file_loader'\n\nSTORAGE = 'thumbor.storages.mixed_storage'\nSECURITY_KEY = 'example'\n\nALLOW_UNSAFE_URL = True\nFILE_LOADER_ROOT_PATH = '/vagrant/images'\n\nREDIS_STORAGE_SERVER_HOST = 'example.com'\nREDIS_STORAGE_SERVER_PORT = 6379\nREDIS_STORAGE_SERVER_DB = 0\nREDIS_STORAGE_SERVER_PASSWORD = None\n\nMIXED_STORAGE_CRYPTO_STORAGE = 'tc_redis.storages.redis_storage'\nMIXED_STORAGE_DETECTOR_STORAGE = 'tc_redis.storages.redis_storage'\n\nDETECTORS = [\n   'thumbor.detectors.face_detector',\n   'thumbor.detectors.profile_detector',\n   'thumbor.detectors.glasses_detector',\n   'thumbor.detectors.feature_detector'\n]\n```\n"},"comment":{"url":"https://api.github.com/repos/thumbor/thumbor/issues/comments/363261834","html_url":"https://github.com/thumbor/thumbor/issues/753#issuecomment-363261834","issue_url":"https://api.github.com/repos/thumbor/thumbor/issues/753","id":363261834,"user":{"login":"heynemann","id":60965,"avatar_url":"https://avatars2.githubusercontent.com/u/60965?v=4","gravatar_id":"","url":"https://api.github.com/users/heynemann","html_url":"https://github.com/heynemann","followers_url":"https://api.github.com/users/heynemann/followers","following_url":"https://api.github.com/users/heynemann/following{/other_user}","gists_url":"https://api.github.com/users/heynemann/gists{/gist_id}","starred_url":"https://api.github.com/users/heynemann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/heynemann/subscriptions","organizations_url":"https://api.github.com/users/heynemann/orgs","repos_url":"https://api.github.com/users/heynemann/repos","events_url":"https://api.github.com/users/heynemann/events{/privacy}","received_events_url":"https://api.github.com/users/heynemann/received_events","type":"User","site_admin":false},"created_at":"2018-02-05T23:54:57Z","updated_at":"2018-02-05T23:54:57Z","author_association":"OWNER","body":"That`s good to know! :)"}}
{"actor":{"display_login":"heynemann"}}