Kitura / Kitura/BlueSocket

Memory leak when using Socket.readString

Open
#190 1 comment 0 reactions 1 assignee Claimed by @adam-rocska View on GitHub
Dominant language
Swift
Stars
1.4k
Forks
193
PR merge metrics
No merged PRs in 30d

Description

The following code results in a big amount of memory being allocated by the process that is not being released.
After 20k connections, the used memory of the process is more than 100MB. After removing the call to `readString`, the memory usage does not increase anymore. I tested this with BlueSocket 1.0.52.

```
var i = 0
while true {
let socket = try Socket.create()
try! socket.connect(to: "localhost", port: 31337)
let serviceResponse = try! socket.readString()!

i += 1
print(i, String(describing: serviceResponse))
Thread.sleep(forTimeInterval: 0.001)
}
```

The socket connects to a service that first responds with "foobar" and then closes the connection.

The code for reproducing this can be found in the repository https://github.com/johannes87/TestBlueSocketMemoryLeak

The target `TestService` inside the Xcode project is the "foobar" service mentioned above.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.