question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Memory leaks in iOS

See original GitHub issue

When 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. screen shot 2018-12-10 at 1 26 39 pm screen shot 2018-12-10 at 1 26 50 pm 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:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
rajivshah3commented, Feb 11, 2019

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

2reactions
rajivshah3commented, Jan 16, 2019

@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?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found