Repeated use of RestRequest leaks memory (via URLSession and URLSessionConfiguration)
mman opened this issue · comments
I have created a simple program that demonstrates how repeated use of RestRequest.response()
leaks memory quite fast.
Please see here: https://github.com/mman/leaky-swifty-request
The leak is happening on both Mac and Linux and seems to be caused by the fact that URLSession(configuration: URLSessionConfiguration)
itself is leaking internally due to retain cycle.
The workaround at least for me seems to be to use URLSession.shared
by default. I'll send PR in the next few days if confirmed to be working stable.
This is the problematic line https://github.com/IBM-Swift/SwiftyRequest/blob/master/Sources/SwiftyRequest/RestRequest.swift#L30.
May be related to #59.
A fix has been delivered in SwiftyRequest 2.0.6 - please try this version at your convenience.