manual memory management

H. S. Teoh hsteoh at quickfur.ath.cx
Wed Jan 9 13:00:07 PST 2013


On Wed, Jan 09, 2013 at 09:03:17PM +0100, Rob T wrote:
> On Wednesday, 9 January 2013 at 03:05:34 UTC, H. S. Teoh wrote:
[...]
> >You *could* load plugins as separate processes and communicate via
> >some kind of IPC mechanism, like Unix pipes. But that's a royal pain
> >(requires serialization / deserialization, with the associated
> >overhead, and a network stack or equivalent, just to interface with
> >each other).
[...]

Another disadvantage is the need for every plugin to have a runtime,
since they'll need to start on their own (as a process, that is, even if
it's the parent app that actually exec()s the process).


> The messaging concept does have some advantages. For example, if
> your external "plugin" fails for any reason (for example due to a
> segfault), the rest of your main application can continue operating
> just fine.

Hmm. I was leaning against using separate processes, but this may just
convince me to favor it. I have been the victim of way too many browser
plugin malfunctions, which inevitably brings down the entire browser.
Recent browsers started using plugin wrappers that can handle plugin
crashes, etc., which is an indication of the need of this kind of
insulation. The fact that plugin wrappers don't always work very well is
another factor that's pushing me in favor of using completely separate
processes.


> There are other advantages, such as distributed processing, but if you
> can benefit from those advantages depends entirely on what you are
> attempting to achieve. The simplest use case that gives you a good
> subset of the main advantages, is through runtime loaded plugins.
[...]

True. Using separate processes also incurs performance overhead -- for
example, I have a C++ program that dynamically loads plugins that
compute the value of some opaque mathematical function, from which a
rather large sample set is repeatedly taken.  The reason I elected to
use plugins is because the precompiled computation code runs faster --
every sample incurs just the cost of a single function call. If I were
forced to make these plugins external processes, the performance hit
would be so bad that I might as well just resort to using a boring old
expression interpreter instead.


T

-- 
MACINTOSH: Most Applications Crash, If Not, The Operating System Hangs


More information about the Digitalmars-d mailing list