29Aug

Memory Management in iOS

Memory Management iOS

In this blog we will walk through very important thing which all iOS developer should  always need to take care while developing  apps for same.

We will  see  few topics related to this thing which is below :-

  • What is the term memory management?
  • What may happen if we don't do memory management in iOS apps?
  • Why do we need to do memory management?
  • How to do memory management,i.e what all posibilities are there through which we can take care of memory in apps?

What is the term memory management?

Memory management  is to reduce the memory footprint of a program by controlling the lifetime of all its objects.So whenever we are creating objects we need to take care of ownership as long as it has to be that means till what extent we have to use of these objects but no longer.Before Xcode 4.2 we had to do all these things manually like if we allocate any object we need to release that object after use i.e we had to take care of retain, release, and autorelease but Xcode 4.2 and in future version they introduced one nice feature ARC which autometically take care of memory management that mean we can say it takes care of object ownership by itself.

What may happen if we don't do memory management in iOS apps?

AS simple as that app might be getting crash.

 

Why do we need to do memory management?

Ofcource we will not allow our apps to get crash so we need to take care of memory which is going to be consumed by app.

What is the reason of crash ?

Not freeing data that is no longer in use causes memory leaks. A memory leak is where allocated memory is not freed, even though it is never used again. Leaks cause your application to use ever-increasing amounts of memory, which in turn may result in poor system performance or (in iOS) your application being terminated.

 

How to do memory management,i.e what all posibilities are there through which we can take care of memory in apps?

Here first we will see the memory management rule then will focus on ARC feature i.e how to do memory management using ARC.

Memory management rule:-

  • We own the objects we create and we have to subsequently release them when they are no longer needed.
  • Retain can be used to gain ownership of an object that we did not create. We have release these objects too when it's not needed.
  • Don't release the objects that we don't own.

Memory management using ARC:-

In this case you don't have to relase objects manually.Whenever we create project it gives the option to check ARC.If you check this then it will take care of object ownership autometically that means object will no longer if don't have need.

 

Note: You can analyze the usage of memory with the help of Xcode tool Instruments. It includes tools like activity monitor, Allocations, leaks, zombies and so on.
 

Related

Access Control in Swift 3

End of this blog you will be able to understand the Access control specifiers open, public,internal,...

Read More >

How to handle the exceptions using recovery scenario manager in QTP?

VB script Error HandlingDurning run time, if QTP encounters any erorr then it will display the error...

Read More >

Creating Apps Using Phonegap Framework in IOS

Creating apps for different operating system is not a reliability so for reducing developr work for ...

Read More >

Implementing iOS Setting Bundle

 iOS Setting Bundle:-Actually sometimes we need to interact our app i.e giving some input value...

Read More >

Base64 encoding in Objective c

When we have some binary data that need to send across network, we generally don't do it by just...

Read More >

Wireless Ad-Hoc distribution for iOS apps

Creating Ad-Hoc is an important part of iOS app development because it helps us in testing the app d...

Read More >

iOS qrcode generator

Have you heard of QR Codes yet? Here is a quick introduction:- QR is short for Quick Response . It i...

Read More >

How to Create a Provisioning profile for iOS

To Run an app on iOS device,you must have a Provisioning Profile installed on your device. ...

Read More >

How to check network reachability in iOS

What is network reachability? Now, you are all set to program your app on the ios device? Here is on...

Read More >

Share

Post a Comment

  • Recent
  • Popular
  • Tag
Monthly Archive
Subscribe
Name

Contact Us
  • *
  • *