Skip to content

Commit

Permalink
Remove memoization of Channel objects
Browse files Browse the repository at this point in the history
Unnecessary memory leak
  • Loading branch information
mloughran committed Nov 12, 2012
1 parent fbc6423 commit 5306e6f
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 8 deletions.
3 changes: 1 addition & 2 deletions lib/pusher/client.rb
Expand Up @@ -111,8 +111,7 @@ def webhook(request)
# configured
def [](channel_name)
raise ConfigurationError, 'Missing client configuration: please check that key, secret and app_id are configured.' unless configured?
@channels ||= {}
@channels[channel_name.to_s] ||= Channel.new(url, channel_name, self)
Channel.new(url, channel_name, self)
end

# Request a list of occupied channels from the API
Expand Down
6 changes: 0 additions & 6 deletions spec/client_spec.rb
Expand Up @@ -155,12 +155,6 @@
@channel.should be_kind_of(Pusher::Channel)
end

it "should reuse the same channel objects" do
channel1, channel2 = @client['test_channel'], @client['test_channel']

channel1.object_id.should == channel2.object_id
end

%w{app_id key secret}.each do |config|
it "should raise exception if #{config} not configured" do
@client.send("#{config}=", nil)
Expand Down

0 comments on commit 5306e6f

Please sign in to comment.