Buy any Easy Native Extensions 2nd Edition package and get our $99 iOS + Android ANE Template completely free before the end of June 2015.
- step-by-step guide to making your iOS extension in under an hour
- library for data conversion between ActionScript and native code
- tutorials
- infographics
- code included
Yesterday we saw how a Native Extension is loaded in memory: what calls are made and in what order. Unloading the extension follows a similar scenario, except:
- unloading can be triggered by one of three different things – have a look at 1a, 1b and 1c on the diagram below;
- there is no guarantee that an extension will be unloaded at all. This is an example of the calls that happen in an iOS ANE:
1. Unloading is triggered
To cause an extension to be unloaded, one of three things (but not all three) needs to happen:
1a. The app shuts down and is unloaded from memory.
1b. Your AIR Libary calls
1 |
myContext.dispose(); |
1c. The AIR Runtime garbage collector detects no references to your extension context and disposes of it.
2. AIR calls the Extension Context Finalizer
The unload trigger causes the Runtime to call the context finalizer function. The role of this function is to allow you to clean up any context-specific resources you might have allocated.
See details on what the context finalizer looks like in C and in Java.
3. AIR calls the Extension Finalizer
At this step the Runtime calls the extension finalizer function, where any global extension-specific data can be cleaned up.
See details on what the extension finalizer looks like in C and in Java.
What else?
Important terminology:
- Extension Initializer
- Extension Context
- Extension Context Initializer: see implementations in C and in Java
Here is also a reminder of what happens when your extension is loaded in memory.
Next, we will get to the meat of an extension and discuss how function calls are made. There be pictures!
Over to you
At what stage is your ANE at the moment? What’s stopping you from finishing it? Let us know in the comments below.
Leave a Reply