Unloading your ANE – order of operations

Opt In Image
Early bird offer on the ANE eBooks

 

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

Finalization Sequence Diagram

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 

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:

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.


Warning: count(): Parameter must be an array or an object that implements Countable in /home/easyna6/public_html/easynativeextensions_wp/wp-includes/class-wp-comment-query.php on line 399

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">