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-4666] Dictionary bridge is leaking memory #47243

Closed
palimondo mannequin opened this issue Apr 22, 2017 · 10 comments
Closed

[SR-4666] Dictionary bridge is leaking memory #47243

palimondo mannequin opened this issue Apr 22, 2017 · 10 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. memory leak bug: Memory leak standard library Area: Standard library umbrella

Comments

@palimondo
Copy link
Mannequin

palimondo mannequin commented Apr 22, 2017

Previous ID SR-4666
Radar rdar://problem/31788785
Original Reporter @palimondo
Type Bug
Status Resolved
Resolution Done
Environment

swift[master] at the time of report

Additional Detail from JIRA
Votes 0
Component/s Standard Library
Labels Bug, Leak
Assignee @aschwaighofer
Priority Medium

md5: 18d4ac6029a7d7afaf3318f44c1c2f65

relates to:

  • SR-4667 Array is probably leaking memory
  • SR-4668 NSStringRef is probably leaking memory

Issue Description:

Running DictionaryBridge performance test from Swift Benchmark Suite reveals a massive memory leak:

$ /usr/bin/time -lp $BUILD/bin/Benchmark_O --num-samples=1 DictionaryBridge
[...]
  17301504  maximum resident set size
[...] 
$ /usr/bin/time -lp $BUILD/bin/Benchmark_O --num-samples=3 DictionaryBridge
#,TEST,SAMPLES,MIN(us),MAX(us),MEAN(us),SD(us),MEDIAN(us)
[...]
  33226752  maximum resident set size
[...]
$ /usr/bin/time -lp $BUILD/bin/Benchmark_O --num-samples=20 DictionaryBridge
[...]
 137551872  maximum resident set size
number of iterations MAX_RSS
1 17 MB
3 33 MB
20 137 MB

Same problem manifests when running benchmarks for ObjectiveCBridgeToNSDictionary and ObjectiveCBridgeToNSSet.

@belkadan
Copy link
Contributor

@swift-ci create

@belkadan
Copy link
Contributor

I suspect these all just need an autorelease pool around test runs.

@palimondo
Copy link
Mannequin Author

palimondo mannequin commented Apr 24, 2017

I hope you're right. But it is strange they vary so much between runs, too. Actually, it was the significant variance between runs with same --num-samples that triggered my investigation. I'm arguing in PR #8793 that benchmarks ought to be memory stable, and there should be no need to average MAX-RSS in the benchmark suite. Having non-deterministic behavior, even manifesting as variance in memory consumption seems like a symptom of a bug to me. Thoughts?

@aschwaighofer
Copy link
Member

#9027

@aschwaighofer
Copy link
Member

and #9031

@palimondo
Copy link
Mannequin Author

palimondo mannequin commented Apr 26, 2017

Verified fixed.

@palimondo
Copy link
Mannequin Author

palimondo mannequin commented Apr 26, 2017

These tests are now memory stable, the variance in MAX_RRS between runs as well as between different --num-samples is very low. CV=0,07%.

@palimondo
Copy link
Mannequin Author

palimondo mannequin commented Apr 26, 2017

aschwaighofer@apple.com (JIRA User) Reopening. Only DictionaryBridge was fixed. ObjectiveCBridgeToNSDictionary and ObjectiveCBridgeToNSSet in ObjectiveCBridging.swift still need similar fix.

@aschwaighofer
Copy link
Member

Yep one more file

@aschwaighofer
Copy link
Member

#9036

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. memory leak bug: Memory leak standard library Area: Standard library umbrella
Projects
None yet
Development

No branches or pull requests

2 participants