nishant

6
WAYS TO INVOLVE MEMORY MANAGEMENT IN SWIFT iOS

Upload: tbinishant

Post on 05-Jan-2021

11 views

Category:

Technology


0 download

DESCRIPTION

When an IOS application runs on the Apple devices, it occupies a chunk of memory in RAM to store all the instances of the class. This chunk of memory is known as a heap. When iOS app development agency talks of memory management, they usually refer to the management of this memory heap.

TRANSCRIPT

Page 1: Nishant

WAYS TO INVOLVE MEMORY

MANAGEMENT IN SWIFT

iOS

Page 2: Nishant

WHAT IS MEMORY MANAGEMENT?

When an IOS application runs on the Apple devices, it occupies a chunk of memory in RAM to store all the instances of the class. This chunk of memory is known as a heap. When iOS app development agency talks of memory management, they usually refer to the management of this memory heap.

MEMORY MANAGEMENT

Page 3: Nishant

MEMORY MANAGEMENT RULES

We own the objects we create, and we have to subsequently release them when they are no longer needed.

Don't release the objects that you don't own.

Use Retain to gain ownership of an object that you did not create. You have to release these objects too when they are not needed.

Page 4: Nishant

STEPS FOR ANALYZING MEMORY ALLOCATIONSStep 1 − Open an existing application.

Step 2 − Select Product and then Profile as shown below.

Step 3 − Select Allocations in the next screen shown below and

select Profile.

Step 4 − We will see the allocation of memory for different

objects as shown below.

Step 5 − You can switch between view controllers and check

whether the memory is released properly.

Step 6 − Similarly, instead of Allocations, we can use Activity

Monitor to see the overall memory allocated for the application.

Step 7 − These tools help us access our memory consumption

and locate the places where possible leaks have occurred.

Page 5: Nishant

INVOLVE MEMORY MANAGEMENT IN SWIFT

Also, although automatic reference counting makes memory management a piece of cake for merchants but it’s not always a perfect solution. As in certain cases, developers might accidentally end up creating a strong reference cycle.

Merchants can easily use automatic reference counting to handle memory management. With the help of automatic reference counting, developers can easily allocate the memory needed to store the instances and values related to them. Also, this concept aids merchants to track the variables, constants, and properties efficiently.

Further, to manage the memory of IOS application merchants must also use best practices like using lightweight UI components and less amount of boilerplate code.

Page 6: Nishant

THANKYOU!Does anyone have question?

SWIFT

Contact us [email protected]+1 954-379-2149

THE BRIHASPATI INFOTECHiOS App Development Agency