Thanks to visit codestin.com
Credit goes to github.com

Skip to content

rpclib leaks and crashes after ~1000 consecutive connections to an rpclib server #125

Closed
@timotheecour

Description

@timotheecour

@sztomi

a simple rpclib server will eventially crash after ~1000 consecutive connections.
Looks like the server doesn't properly release the connection to a client after client goes out of scope. How would I properly close the client?

test_leak crashes, test_no_leak doesn't crash.

void test_leak(){
  for(int counter=0; ; counter++){
    rpc::client client(host, port);
    auto response = client.call("fun", "arg").as<string>();
  }
}

void test_no_leak(){
   rpc::client client(host, port);
   for(int counter=0; ; counter++){
     auto response = client.call("fun", "arg").as<string>();
  }
}
  • ls -l /proc/$pid/fd | wc -l keeps increasing
  • htop shows memory keeps increasing
  • lsof -p $pid keeps increasing, showing entries such as:
binary $pid user  ...     IPv4 ...      0t0      TCP localhost:18700->localhost:39692 (ESTABLISHED)

EDIT:
for the server, use this for eg:bind("fun", []() { return ""; });

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions