From: Robert Dailey (rcdailey_at_[hidden])
Date: 2008-07-14 10:30:29


On Fri, Jul 11, 2008 at 12:02 PM, Jeremy Pack <rostovpack_at_[hidden]> wrote:

> Robert,
> Could you be a little bit more specific as to what you'd like? What is the
> exact use case?
>
> When a shared library is loaded, it is shared by all processes using it. It
> is also unloaded in the way memory can be handled by a garbage collecter -
> some time after all references to it have been removed.
>
> As such, the first process to load it is, in effect, buffering it into
> memory, and other processes can then load it very cheaply.
>
> As far as loading it directly from a memory buffer, that would require
> copying a bunch of routines from the platform-specific functions that fix
> pointer references, function references, type information etc. within a
> shared library when it is loaded.
>
> If you're sending shared libraries over a network connection between
> computers, I can see how this might possibly be more optimal. But if you're
> shooting to make your program that heavily optimized, I'd recommend
> assembly
> language :)
>
> So, yes, it is possible. No, I don't think it is worth attempting.

Thanks for responding Jeremy.

My use case was simple. I would receive a DLL in memory over a network, and
instead of first writing it to a file and THEN opening it, I was hoping I
could just read it from memory as if it were a file. However, I've found out
that I no longer need to do this. I'll first be writing it to a file, so
this feature would no longer be needed.

Thanks for emphasizing a few good points about this, it's probably best to
keep it on the file system.