• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Cocoa classes and plug-in bundle (dylib) in-memory lifetimes (AU, x64, ObjC)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Cocoa classes and plug-in bundle (dylib) in-memory lifetimes (AU, x64, ObjC)


  • Subject: Cocoa classes and plug-in bundle (dylib) in-memory lifetimes (AU, x64, ObjC)
  • From: "Angus F. Hewlett" <email@hidden>
  • Date: Sat, 09 Apr 2011 13:42:43 +0100

Hi all,

Apologies for cross-posting - having some difficulty getting a definitive answer on this one.

Trying to clarify the runtime behaviour of Cocoa-UI-based AU bundles, in relation to module load & unload, and what the correct behaviour should be.

Specifically:- since OS X 10.5, bundles (dynamic libraries) implementing Objective-C code may be unloaded at run time (and, in theory, reloaded), but ObjC classes cannot be unregistered / re registered. The OS X documentation states that "the caller must ensure that it does not refer to classes whose bundle has been unloaded", or words to that effect. This, potentially, creates a situation where (VST, AU) plug-ins can be UNloaded by a host, but any attempt to REload them will cause a crash (when the plug-in tries to access its classes, which are already registered with the ObjC runtime at an old memory address).

What I'm wondering is this:- are plug-in bundles ever actually unloaded by hosts or the OS in practice on 64-bit Mac OS X? It seems that on a system with hundreds (thousands?) of plug-ins, it would not be desirable to allow unwanted bundles to remain in memory (even with a 64 bit virtual memory manager) - but unloading and reloading would not appear to work, unless all plug-in bundles are coded so as to synthesize unique ObjC class names every time they're loaded. (FWIW, on 32-bit Mac OS X it was routine for plug-ins to be unloaded and reloaded as needed by the host, but for the vast majority the UIs were written in C++ to the Carbon/HIObject APIs so there was no ObjC class registration going on).

I've done some testing with Logic Pro 9, Cubase 6 & Studio One 1.6, and so far have never observed my bundles being unloaded at runtime, but I've not put the system under real stress & I can't be absolutely sure that the reason they're not unloading is some component of mine that's holding a retain on the bundle.

So, my questions are as follows:-

* Should hosts *ever* attempt to unload plug-in bundles on 64-bit Mac OS X?

* If *YES*, does this imply that all ObjC classes in plug-ins MUST be runtime synthesized with unique names per module-load? (to solve potential reload-at-different-address class registration bugs)

* If *NO*, does this imply that plug-ins should be extremely frugal with load-time "module lifetime scope" static initialization / uninitialization (bearing in mind the modules will be kicking around in memory much longer than any active instance of the plug-in)?

FWIW, we have until now used module lifetime scope to init/uninit a bunch of stuff (mostly fairly lightweight objects like logs and timers, but still), if plug-in bundles should be assumed to stay in memory forever (which rather sounds like a memleak to me, actually...) once loaded, we need to be much more frugal with that stuff & not assume our unload-time uninitialization routines will ever be called (at quit, Cocoa apps seem to like to terminate() without a symmetric cleanup of the underlying C/C++ runtime). We want to synthesize our Cocoa class names at compile time, not run time, as building everything from scratch "C" code at runtime means we lose a lot of the niceties of ObjC.

Thanks & best regards,

    Angus.
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Cocoa classes and plug-in bundle (dylib) in-memory lifetimes (AU, x64, ObjC)
      • From: Paul Davis <email@hidden>
  • Prev by Date: Re: AU Threading Question
  • Next by Date: Re: Cocoa classes and plug-in bundle (dylib) in-memory lifetimes (AU, x64, ObjC)
  • Previous by thread: Re: what should a host do when ....
  • Next by thread: Re: Cocoa classes and plug-in bundle (dylib) in-memory lifetimes (AU, x64, ObjC)
  • Index(es):
    • Date
    • Thread