Home / iPhone

Memory Management in IOS Application Development - IPhone

Rating: 5.0Blog-star
Views: 2662
by Rajesh Shetty
Last modified: March 2nd 2021

iPhone Memory Management

>> Modern computer languages use garbage collection (GC). A GC is a runtime algorithm that scans the allocated objects in our program and de-allocated the objects that we have lost contact.

>> Concave under the I phone doesn’t use GC. So concave applications must use managed memory application running this platform should clean up after use since I phone apps run in a memory con train environment.

If you want to become a IOS Certified Specialist, then visit Mindmajix - A Global online training platform: “IOS Development Training Online”.  This course will help you to achieve excellence in this domain.

Keywords for memory management:

1. Retain
2. Release
3. Auto release
4. Copy
5. Auto Release Pool
6. Drain

1) Retain:

This specifies that you are instead in putting an ownership client on the object if the color release the object it doesn’t de-allocated because you retained it. Increases the retain count ‘1’

Syntax:- [obj retain];

2) Release:

We call release when we use done using an object we are no longer the owner of the object. So reference count is decreased by owner.

  • If the reference count is zero [no owner left]

Then the object is automatically deleted and memory is freed otherwise the object states in memory for another owner to use.

Syntax:- [obj release];

3) Auto release:

This means that you need the object temporarily, and doesn’t make you an owner.

It just like saying I need this object is noun keep it in memory while I do a few things with it then you can delegate it.
Ex:-
object code

4) Copy:

This object creates a copy of the objects and you become the owner of the new object.

Syntax:- Ns string *str= [str2 copy];

5) Auto release pool:

An autorelease pool is an instance of ns auto-release class and defines a slope for temporary objects [objects which are to be auto release]

  • Any objects which are to be auto release (objects we send auto release message0.
  • (Created with convenes methods) are added to the current autorelease pool when the auto release pool is released all objects that were added to it are also automatically release.
  • This is simple way of managing automatic release for objects which are needed temporarily
  • Auto release pool can be nested in this case all auto-release objects are added to latest the pools are stored in a stack
NS auto release pool * pool= [(NSAutoReleasePool alloc]int];
//str is auto release object adding to the pool.
Ns string *str = [NSString  stringwithstring:@”Hai”];
// when release pool it sends release message to all objects of its;

6) Drain:

When we pass the drain for the object it deallocates all the objects in a pool.
Ex:- [pool drain];

Distribution of iPhone App

In preparing your device to install iPhone apps we have to create decertificates.

  • CSR
  • Development certificate
  • Provisioning/distribution profile
  • App id generation

[Related Article: Check Out iPhone Tutorial]

a) CSR (certificate signing request):

It contains information used to generate your development certificate this certificate is developed in the key chain is present in MAC os

 development certificate

b) Development certificate:

A development certificate identifies an IOS application developer after the CSR is approved we download the developer certificate from the portal and added to the key chain.

  • When we build the application with x code it looks for your development certificate in your key chain.
  • If it finds the certificate x code sign your application otherwise it gives a build error.

c) Provisioning profile:

It is generated from the portal whenever we install the provisioning profile and I phone the device becomes alive for developing the application through x code.

  • the provisioning profile is an individual user
  • Distributing profile is a many nor of user

Eg:- USA friend

Device registration: Apple provides 100 devices testing for the standard program every I phone as the unique device it is a 40 digit nor you should register this in the portal.

d) App id generation:

Every application has a unique app ID it is also generated from the portal.

Note:- Distribution of over app to the device can be done through distribution profile, and we should convert over final product app file IPA this over distribution is called ad hoc distribution.

Frequently Asked iPhone Interview Questions & Answers

About Author

author
NameRajesh Shetty
Author Bio

Technical Content Writer