You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems to take up double the memory when use try clientRequest.content.encode(Encodable.self, as: .formData).
In addition,
when the request fails, the memory will not be released normally (still taking up double the memory).
After the request is successful, the memory will be released normally.
Have you tried to test the memory footage in release mode too, or just in debug mode?
The form-data encoder has a known issue of taking up too much resources in debug builds, unlike in release builds where it performs just like it should.
Have you tried to test the memory footage in release mode too, or just in debug mode?
The form-data encoder has a known issue of taking up too much resources in debug builds, unlike in release builds where it performs just like it should.
publicstructVideoPayload:Codable,Content{varvideo:File?// << important use Optional<File>varthumbnail:File?// << important use Optional<File>publicinit(video:File, thumbnail:File){self.video = video
self.thumbnail = thumbnail
}mutatingpublicfunc clear(){
video =nil
thumbnail =nil}}varpayload=VideoPayload(
video:File(
data:ByteBuffer(data:tryData(contentsOf:URL(fileURLWithPath: video.videoPath))),
filename:(video.videoPath asNSString).lastPathComponent
),
thumbnail:File(
data:ByteBuffer(data:tryData(contentsOf:URL(fileURLWithPath: thumbPath))),
filename:(thumbPath asNSString).lastPathComponent
))letresponse=tryawait app.client.post(uri){ cr in// &payload, without copy datatry cr.content.encode(&payload, as:.formData)// clear data in memory << ⚠️ see here, clear File after encoded
payload.clear()}
Describe the bug
It seems to take up double the memory when use
try clientRequest.content.encode(Encodable.self, as: .formData)
.In addition,
when the request fails, the memory will
not be released
normally (still taking up double the memory).After the request is successful, the memory will be released normally.
Environment
The text was updated successfully, but these errors were encountered: