Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-5054] String(contentsOf: url, encoding: .utf8) memory leak #4097

Closed
swift-ci opened this issue May 31, 2017 · 2 comments
Closed

[SR-5054] String(contentsOf: url, encoding: .utf8) memory leak #4097

swift-ci opened this issue May 31, 2017 · 2 comments

Comments

@swift-ci
Copy link
Contributor

Previous ID SR-5054
Radar None
Original Reporter sdidanov (JIRA User)
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Foundation
Labels Bug, Linux
Assignee None
Priority Medium

md5: 83f10bbe85ce35e1dc6162030b868a31

Issue Description:

I have a memory leak using swift:

let htmlString = try? String(contentsOf: url, encoding: .utf8)

on Ubuntu 16.04, swift-3.1.1-RELEASE. I got htmlString a lot of times per second.

Also, this action create in /tmp files like:

3620C99A-5E98-4E6B-B4D4-CAE6BADDF824.tmp
66B8F1AC-1509-41FA-B1D9-9554A0AD005B.tmp
9811F77C-0F3A-4AAD-80B3-E7DDF052CAEA.tmp
A97F67BC-B7A4-41CA-99F1-FA82C6742892.tmp
AD688B9C-4258-40C4-902B-E503F484EFE3.tmp
B18EF8F8-EC83-4483-9F3D-8229BC989801.tmp
C15A0404-BBF9-4575-9DC8-4512AAFA596B.tmp
D5610B38-2D03-4161-8D0A-ECAC187431BD.tmp
EF9C9128-EA83-4958-A8AF-393903B721EF.tmp

And do not remove them.

How to fix this?

@swift-ci
Copy link
Contributor Author

Comment by Sergey Didanov (JIRA)

I found that this tmp files also generated after downloading page using URLSession. But this files do not delete automatically. In my case after some hours of application work, it use all available inodes on / file system.

@spevans
Copy link
Collaborator

spevans commented Mar 30, 2020

This has been fixed since Swift 4.2

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 5, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants