Delphi mobile compilers based on LLVM use ARC or Automatic Reference Counting, as Embarcadero detailed on several blog posts and I covered in my Delphi Mobile Language White Paper. The coming Android ARC compiler, also based on LLVM, shares the same technologies with its iOS twin, including ARC support.
Now on the iOS platform, using ARC is very common, as this is the default memory management solution for Apple's Xcode development tool. On iOS Delphi shares most of the toolchain with the "platform solution" (that is, Xcode) which uses LLVM and ARC.
This solutions has several advantages. First, by sharing the same memory management model across mobile platforms, we let developers optimize their code for it. Second, we have a more deterministic objects destruction, compared to GC-based languages. Third, we don't need a to "stop" our application to manage memory, as all memory management is done directly by the program as required. Fourth, when ARC is properly used (with weak references and other techniques) the memory consumption remains lower than an average GC solution. Fifth, it is a "true native" solution, as we like calling it. Sixth, you can hook in many ways into Delphi memory management, customizing it far more than any other development tool (you can replace the memory manager, customize it on a per-class basis, implement different AddRef and Release methods...). Seventh, you have the complete source code of the memory management routines.
Drawbacks? Yes, there are some. For sure, there are a couple of tricks you need to learn to use ARC, specifically if you are coming from a desktop development (aka, Delphi VCL) background. You need to learn how to write code in the ARC-way, like:
class procedure TMySimpleClass.CreateOnly; var MyObj: TMySimpleClass; begin TheForm.Log ('Starting CreateOnly'); MyObj := TMySimpleClass.Create; MyObj.DoSomething; TheForm.Log ('Done with CreateOnly'); end;
This method will release the memory of the MyObj object as it reaches the end statement. You need to figure out how to write code that works both on desktop and mobile, like the following (which is probably the code you already have, and it does work as expected):
class procedure TMySimpleClass.TryFinally;
TheForm.Log ('Starting TryFinally');
MyObj := TMySimpleClass.Create;
TheForm.Log ('Done with TryFinally');
The different is that this method will release the object earlier, at the Free call, as you can see in the output below:
And, yes, you need to learn about Weak references and some advanced coding patterns. And possibly about DisposeOf (although this is rarely needed), and other capabilities.
With a GC you have generally little or no control, unlike with ARC. So while it might be easier to use a GC if you have a lot of memory to spare (like on a dektop or on a server). When it comes to fine tuning and advanced capabilities a GC might really fall short and ARC offers much more flexibility to a developer.
That's why it is great to have ARC available on Android, a Delphi first. Coming soon...
PS. You can buy Delphi XE4 with Mobile today and get Android for free when it ships. This and other special offers at embt.co/XE4RadOffer.