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
ubuntu@ubuntu-yakkety:~$ swift --version
Swift version 3.1-dev (LLVM a7c680da51, Clang f186e73135, Swift 5c7823ca8c)
Target: x86_64-unknown-linux-gnu
ubuntu@ubuntu-yakkety:~$ uname -a
Linux ubuntu-yakkety 4.8.0-37-generic #39-Ubuntu SMP Thu Jan 26 02:27:07 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
Additional Detail from JIRA
Votes
1
Component/s
Foundation
Labels
Bug, 3.1Regression, Leak, Linux
Assignee
saiHema (JIRA)
Priority
Medium
md5: 786a9cce487d231f6c1fea6bba5f4fb2
Issue Description:
Running a simple loop that creates `NSMutableData` objects and appends to them, I get a pretty obvious memory leak (according to `ps` and `valgrind`) under `swift-3.1-DEVELOPMENT-SNAPSHOT-2017-02-14-a-ubuntu16.10` `Swift version 3.1-dev (LLVM a7c680da51, Clang f186e73135, Swift 5c7823ca8c)`.
This did not happen under 3.0.2.
Code attached, but it basically:
```
for i in 0..<100 {
var fileData = NSData(contentsOfFile: "/usr/lib/git-core/git")
if let fileData = fileData {
var fileDoubleData: NSMutableData = NSMutableData(bytes:fileData.bytes, length:fileData.length)
fileDoubleData.append(fileData.bytes, length:fileData.length)
}
}
```
`valgrind --tool=memcheck` says:
```
==7402== 247,463,936 bytes in 59 blocks are definitely lost in loss record 28 of 28
==7402== at 0x4C2ED5F: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==7402== by 0x54EC372: __CFDataGrow (in /usr/lib/swift/linux/libFoundation.so)
==7402== by 0x54EBBE9: CFDataReplaceBytes (in /usr/lib/swift/linux/libFoundation.so)
==7402== by 0x5687C65: Foundation.NSMutableData.append (Swift.UnsafeRawPointer, length : Swift.Int) -> () (in /usr/lib/swift/linux/libFoundation.so)
==7402== by 0x401491: main (in /home/ubuntu/mem_test)
```
output from `valgrind --tool=memcheck` and `valgrind --tool=massif` also attached.
The text was updated successfully, but these errors were encountered:
} else {
iflethandler = deallocator {
_deallocHandler!.handler = handler
}
// The data initialization should flag that CF should not deallocate which leaves the handler a chance to deallocate instead_CFDataInit(unsafeBitCast(self, to: CFMutableData.self), options | __kCFDontDeallocate, length, bytePtr, length, true)
}
In the case that deallocator == nil, A) handler is not set, and B) CF is instructed not to deallocate. Therefore nobody will clean this up.
deallocator is apparently nil in many of the convenience constructors, including the one in the repro case
Attachment: Download
Environment
ubuntu@ubuntu-yakkety:~$ swift --version
Swift version 3.1-dev (LLVM a7c680da51, Clang f186e73135, Swift 5c7823ca8c)
Target: x86_64-unknown-linux-gnu
ubuntu@ubuntu-yakkety:~$ uname -a
Linux ubuntu-yakkety 4.8.0-37-generic #39-Ubuntu SMP Thu Jan 26 02:27:07 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
Additional Detail from JIRA
md5: 786a9cce487d231f6c1fea6bba5f4fb2
Issue Description:
Running a simple loop that creates `NSMutableData` objects and appends to them, I get a pretty obvious memory leak (according to `ps` and `valgrind`) under `swift-3.1-DEVELOPMENT-SNAPSHOT-2017-02-14-a-ubuntu16.10` `Swift version 3.1-dev (LLVM a7c680da51, Clang f186e73135, Swift 5c7823ca8c)`.
This did not happen under 3.0.2.
Code attached, but it basically:
```
for i in 0..<100 {
var fileData = NSData(contentsOfFile: "/usr/lib/git-core/git")
if let fileData = fileData {
var fileDoubleData: NSMutableData = NSMutableData(bytes:fileData.bytes, length:fileData.length)
fileDoubleData.append(fileData.bytes, length:fileData.length)
}
}
```
`valgrind --tool=memcheck` says:
```
==7402== 247,463,936 bytes in 59 blocks are definitely lost in loss record 28 of 28
==7402== at 0x4C2ED5F: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==7402== by 0x54EC372: __CFDataGrow (in /usr/lib/swift/linux/libFoundation.so)
==7402== by 0x54EBBE9: CFDataReplaceBytes (in /usr/lib/swift/linux/libFoundation.so)
==7402== by 0x5687C65: Foundation.NSMutableData.append (Swift.UnsafeRawPointer, length : Swift.Int) -> () (in /usr/lib/swift/linux/libFoundation.so)
==7402== by 0x401491: main (in /home/ubuntu/mem_test)
```
output from `valgrind --tool=memcheck` and `valgrind --tool=massif` also attached.
The text was updated successfully, but these errors were encountered: