0

While studying Memory management of Mac OS / iOS learnt that an object would get removed from the heap when it has no references pointed to. In java we can call system.gc() for manual garbage collection.

Can someone please tell what is the system process that keeps checking the ARC in iOS and/or Mac OS!

Chandu
  • 630
  • 2
  • 8
  • 18

1 Answers1

2

Before ARC, we kept track of memory by calling the retain method whenever we got a reference to an object, which would increment that object's reference count. When we were done with the reference, we would call release to decrement the reference count. When a reference count reaches 0, the object is deallocated. ARC simply inserts retain and release calls at compile time so it we don't have to worry about it ourselves.

NobodyNada
  • 7,529
  • 6
  • 44
  • 51
  • Thanks. But when the reference count is zero... what is the system process that removes that object from memory? – Chandu Apr 23 '14 at 04:08
  • @Chandu As far as I know, when an object is released, decrementing its reference count, the ref count is checked to see if its zero. – NobodyNada Apr 23 '14 at 15:33