Memory management

Memory management is an important programming principle of handling the life cycles of objects and releasing them when they are no longer needed in your application. Management of object memory is necessary to have good performance; if an application doesn't free unneeded objects, its memory footprint grows and performance suffers.

RubyMotion provides automatic memory management; you do not need to reclaim unused objects. Also, as memory in any iOS device is limited, the bad acting application would just be killed at some point.

Memory management in a Cocoa application that doesn't use garbage collection is based on a reference-counting method. RubyMotion also uses reference-counting ways to reclaim memory. When you create or copy an object, its retain count is 1. Thereafter, other objects may express an ownership interest in your object, which increments its retain count. The owners of an object may also surrender their possession interest in it, which reduces the retain count. When the retain count becomes zero, the object is deallocated (destroyed).

Objects created by Objective-C or the Core-Foundation-style APIs are automatically managed by RubyMotion. There is no need to send the retain, release, or auto-release messages to them, or to use the CFRetain or CFRelease functions.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.220.179.153