Memory leaks in iOS
See original GitHub issueWhen I’m using below code in my app.
Keychain.getGenericPassword()
.then(credentials => {
if (credentials) {
this.setState({
password: credentials.password
});
} else {
return Keychain.setGenericPassword(
'test',
'randomSecret'
).then(() => {
this.setState({
password: 'test'
});
Promise.resolve('randomSecret')
});
}
})
.catch(error => {
this.setState({
password: error.message
});
Promise.reject(error)
});
I’m getting memory leaks. I’m using Xcode instrumentation to identify this leaks. See attached screenshots. This leaks increases continuously until the app is an active.
Below is the app leak area. OSStatus osStatus = SecItemCopyMatching((__bridge CFDictionaryRef) query, (CFTypeRef*)&foundTypeRef);
Let me know whether I’m doing anything wrong.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:6 (3 by maintainers)
Top Results From Across the Web
What Are iOS Memory Leaks and How to Detect Them?
A memory leak is a piece of memory that was allocated at one point but never released, and is also no longer referenced...
Read more >Everything you need to know about Memory Leaks in iOS
A memory leak occurs when a given memory space cannot be recovered by the ARC (Automatic Reference Count) because it is unable to...
Read more >How to detect iOS memory leaks and retain cycles using ...
A memory leak in iOS is when an amount of allocated space in memory cannot be deallocated due to retain cycles. Since Swift...
Read more >Memory Leaks in iOS: Find, Diagnose, & Fix (2022) - YouTube
In this video we will cover memory leaks in iOS apps. We will first do an example to leak some memory and then...
Read more >Detecting Memory Leaks in iOS - Dev Genius
Detecting Memory Leaks in iOS. Learn about memory leaks and how to catch them with Instruments and the memory graph.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Update: The leak was actually coming from
foundTypeRef
, which is a Core Foundation object that we created but didn’t release after we were done using it. I fixed it in #188@Bautista-Baiocchi-lora when I have some time I’ll try the
CFRelease(osStatus)
to see if it resolves the issue. I’m not very experienced with memory management though, so I’m not sure if this is the correct fix. @oblador do you know if this is the right approach?