[gmpi] Re: Linux C++ question

  • From: Tim Hockin <thockin@xxxxxxxxxx>
  • To: gmpi@xxxxxxxxxxxxx
  • Date: Thu, 24 Feb 2005 13:01:33 -0800

On Fri, Feb 25, 2005 at 09:49:22AM +1300, Jeff McClintock wrote:
> >>If we are fully supporting C++, are we able to use static objects in the
> >>SDK? (they can be useful, specifically for singletons).
> >
> > useful but not essential.
> 
> Well, I've got users who create plugins with 400MB Sample Banks (no joke).
>   It's not uncommon for a user to open two instances of a plugin, in 
> which case I prefer to share the samples (via a singleton) rather than 
> consume 800MB of memory.

I don't see how those two are related?  It's easy enough to share things
between instances.  Whether an object is truly static or is just wrapped
up doesn't matter.

Consider (roughly from GMPI factory)

 GMPI_Factory* Factory(void)
 {
        static GMPI_Factory the_factory;
        return &the_factory;
 }

vs

 GMPI_Factory* Factory(void)
 {
        static GMPI_Factory* the_factory;
        if (the_factory == NULL) {
                the_factory = new GMPI_Factory();
        }
        return the_factory;
 }


The overhead is a branch.

----------------------------------------------------------------------
Generalized Music Plugin Interface (GMPI) public discussion list
Participation in this list is contingent upon your abiding by the
following rules:  Please stay on topic.  You are responsible for your own
words.  Please respect your fellow subscribers.  Please do not
redistribute anyone else's words without their permission.

Archive: //www.freelists.org/archives/gmpi
Email gmpi-request@xxxxxxxxxxxxx w/ subject "unsubscribe" to unsubscribe

Other related posts: