Re: Mex vs. Generic DLLs
- From: Peter Boettcher <boettcher@xxxxxxxxxx>
- Date: Wed, 07 Jun 2006 16:40:39 -0400
Please quote some context from preceeding posts when you continue a
thread. You may find that subscribing to comp.soft-sys.matlab using a
regular newsreader, or using the web gateway at www.matlabcentral.com,
will make this easier than the tools deployed at the Math Forum.
JFG <guillochon@xxxxxxxxx> writes:
One more question: Currently, I have a one file with a Mex interface
function. One calls this function from Matlab, with the first
arguement being the name of the C++ function one wants to use, and
the next arguements being the arguements passed to the C++ function.
Currently, all functions are in the same mex function library. If
the project used generic DLLs, I could split up the functions into
several different DLL files, and only load the appropriate libraries
when they are needed. It seems that with Mex, I'd have to load the
entire library into memory whenever I wanted to call a function. Is
this how Mex works? Or is Matlab smart enough to only load the
functions that are called within the library?
This is more an issue of how the operating system handles dynamic
libraries. Either way, I'd think you'd be better off loading all
functions at once, anyway. The code is probably not large, and once
it is loaded, it will stay loaded for a long time. I think load time
will simply not be an issue.
I believe that Windows works essentially the same as Linux with regard
to dynamic libraries. In Linux, a dynamic library is mmap()'d into
the address space of the process. So a given address will now
reference a certain offset of the file. Most of that file is not
actually copied into memory. Instead, as soon as an address (inside
the mmaped region) is accessed, a page fault is generated (meaning the
virtual address has no real address in RAM to map to), and the OS
"pages" in from the disk that page, shows the CPU what the
correspondence is, and processing continues.
The overhead of actually finding, opening, parsing, etc. multiple DLLs
is probably much worse.
--
Peter Boettcher <boettcher@xxxxxxxxxx>
MIT Lincoln Laboratory MATLAB
FAQ: http://www.mit.edu/~pwb/cssm/
.
- References:
- Re: Mex vs. Generic DLLs
- From: Peter Boettcher
- Re: Mex vs. Generic DLLs
- From: JFG
- Re: Mex vs. Generic DLLs
- Prev by Date: Plotting discrete lines between pairs of data without looping
- Next by Date: Re: 'clear all' doesn't clear certain variables
- Previous by thread: Re: Mex vs. Generic DLLs
- Next by thread: Max of 2 3 dimensional arrays
- Index(es):
Relevant Pages
|