How to prevent memory leaks?

I was searching for tools that could help me find memory leaks faster and would be simple in implementation without affecting performance and memory size of application. I found a fantastic fit for this task LifetimeTracker developed by Krzysztof Zabłocki. All you need is to add LifetimeTracker package to the project, inherit from LifetimeTrackable protocol, and add two lines of code. class Department: LifetimeTrackable {} trackLifetime method to init of instance that you are going to verify, and lifetimeConfiguration property where you set max number of valid instances....

December 24, 2023 · 1 min · Dmytro Chumakov

How to find memory leaks?

The common way to find memory leaks is by using Xcode Instruments. All you need is the following: Open Xcode Instruments Choose Leaks option Select Simulator where you are going to test your application Select your installed application When you finish preparation, you can start immediate recoding and check application for leaks. To do that, you need to open Simulator and try some cases that could cause memory leaks. After you spend some time trying different scenarios, you can see that Instruments found Leaked Objects....

December 20, 2023 · 1 min · Dmytro Chumakov