Skip to content

Potential memory leak? #43

Description

@lancecarlson

I'm running this on the client side:

require 'async'
require 'async/http/endpoint'
require 'async/websocket/client'

URL = ARGV.pop || "http://127.0.0.1:7070"

Async do |task|
  endpoint = Async::HTTP::Endpoint.parse(URL)
	
  Async::WebSocket::Client.connect(endpoint) do |connection|
    1000.times do
      connection.send_text("Hello World")
    end
    connection.flush
		
    while message = connection.read
      p message
    end
  end
end

I'm running the server at the bottom example in the guide here:

https://github.com/socketry/async-websocket/tree/main/guides/getting-started

I'm running 3 different clients and closing them, then running them again. Each time checking the memory of the ruby process spawned from the server. Each time it seems to go up without garbage collecting at all. This could wreak havoc on any long running service. Do you have any idea where the leak is coming from? I tried messing with the $connections global to see if the Set was a problem, but I don't think so. It might be related to some weird string allocation thing going on when the incoming message comes through?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions