{"action":"created","issue":{"url":"https://api.github.com/repos/fog/fog/issues/3442","repository_url":"https://api.github.com/repos/fog/fog","labels_url":"https://api.github.com/repos/fog/fog/issues/3442/labels{/name}","comments_url":"https://api.github.com/repos/fog/fog/issues/3442/comments","events_url":"https://api.github.com/repos/fog/fog/issues/3442/events","html_url":"https://github.com/fog/fog/issues/3442","id":58004913,"number":3442,"title":"Memory leak in Rackspace Cloud Files directory and file calls?","user":{"login":"philayres","id":294874,"avatar_url":"https://avatars.githubusercontent.com/u/294874?v=3","gravatar_id":"","url":"https://api.github.com/users/philayres","html_url":"https://github.com/philayres","followers_url":"https://api.github.com/users/philayres/followers","following_url":"https://api.github.com/users/philayres/following{/other_user}","gists_url":"https://api.github.com/users/philayres/gists{/gist_id}","starred_url":"https://api.github.com/users/philayres/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/philayres/subscriptions","organizations_url":"https://api.github.com/users/philayres/orgs","repos_url":"https://api.github.com/users/philayres/repos","events_url":"https://api.github.com/users/philayres/events{/privacy}","received_events_url":"https://api.github.com/users/philayres/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2015-02-18T00:18:55Z","updated_at":"2016-03-10T20:07:07Z","closed_at":null,"body":"I'm using Fog to access Rackspace Cloud Files within EventMachine. I seem to be getting a memory leak related to the `Rackspace::Service#request` method. At this point I have not managed to separate out the code to make a simple example of the issue, but I'd like to see if the description of my current investigation can trigger any ideas around the real source of the problem. I've tried various Fog versions and have currently landed at 1.27.0 for testing.\r\n\r\nI create a Fog connection up front and to get a single directory by name within an HTTP request handled by EventMachine (em-http-server)\r\n\r\n    service = Fog::Storage.new(req_opt)\r\n    # within an EventMachine deferred request\r\n      service.directories.get(@full_container_name)\r\n    # end the EventMachine request\r\n\r\nI have separated out the Fog stuff, and have just returned data through my server and there is no leak. As soon as I hit service.directories.get the memory usage grows and grows. \r\n\r\nNow if I just do:\r\n\r\n    (0..50).each do |d|\r\n      service.directories.get(@full_container_name)\r\n    end\r\n\r\nThe memory does not grow more than for a single call. So I believe that something is being held onto inside the first call within an EventMachine request.\r\n\r\nIf I do `service.directories.all` the memory does appear to leak too in a similar way, so its not just the `#get` method at fault.\r\n\r\nFor testing, I reduced the call to just do \r\n\r\n   service.directories.do_nothing\r\n\r\nwithin the EM deferred request, where I created a dummy method in the Rackspace::Directories class. The memory does not grow in the same way.\r\n\r\nInside the Rackspace::Real class I created a similar dummy method and call this instead of `Rackspace::Real#get_container`, just to make sure. The memory jumps around a little more but does not grow endlessly.\r\n\r\nThis suggest to me that there is something happening inside the actual request that is not letting go. So I have just returned from `Rackspace::Service#request` immediately before `@connection.request`. Logging the `@connection` variable shows this connection is always the same (as expected). The memory does not grow if I don't call the `@connection.request` method.\r\n\r\nWhen the `@connection.request` is reintroduced the memory grows indefinitely.\r\n\r\nI'm assuming at this point I am close to hitting Excon code. But before I start wasting time over there too, I want to see if any of this discussion means anything to anybody here. I'm open to offers!\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/fog/fog/issues/comments/195025654","html_url":"https://github.com/fog/fog/issues/3442#issuecomment-195025654","issue_url":"https://api.github.com/repos/fog/fog/issues/3442","id":195025654,"user":{"login":"plribeiro3000","id":672952,"avatar_url":"https://avatars.githubusercontent.com/u/672952?v=3","gravatar_id":"","url":"https://api.github.com/users/plribeiro3000","html_url":"https://github.com/plribeiro3000","followers_url":"https://api.github.com/users/plribeiro3000/followers","following_url":"https://api.github.com/users/plribeiro3000/following{/other_user}","gists_url":"https://api.github.com/users/plribeiro3000/gists{/gist_id}","starred_url":"https://api.github.com/users/plribeiro3000/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/plribeiro3000/subscriptions","organizations_url":"https://api.github.com/users/plribeiro3000/orgs","repos_url":"https://api.github.com/users/plribeiro3000/repos","events_url":"https://api.github.com/users/plribeiro3000/events{/privacy}","received_events_url":"https://api.github.com/users/plribeiro3000/received_events","type":"User","site_admin":false},"created_at":"2016-03-10T20:07:07Z","updated_at":"2016-03-10T20:07:07Z","body":"Closing in favor of fog/fog-rackspace#4"}}