memory allocated with mxMalloc

Suppose within an m-file I use a mex file to allocate persistent memory using mxMalloc and mxMakeMemoryPersistent.
When the mex file returns, I then start a batch job and pass the pointer returned by the mex file to the batch job.
Will the batch job be able to access this memory?
More info: A GUI is used to control hardware components which write to the mxMalloc'ed memory block, I would like the batch job to save the data written there in parallel. Don't worry, synchronization will be taken care of.

3 Commenti

Peter Li
Peter Li il 20 Set 2011
Interesting question; I don't have experience with MakeMemoryPersistent, but my intuition is that this will work. You are passing the pointer out and back in as a long or something?
rick
rick il 20 Set 2011
yes, my confusion arises with the matlab memory manager, I couldn't find any documentation as to how it manages multiple matlab processes, i.e. does each process have its own address space managed by separate managers or does one memory manager take care of all processes...thereby allowing memory to be shared (if it was 'smart' and realized a pointer to allocated memory was being passed to another process)
Peter Li
Peter Li il 23 Set 2011
Ah sorry, I didn't realize this was specific to interprocess calls. In that case Edric's suggestion sounds like the way to go.

Accedi per commentare.

 Risposta accettata

Edric Ellis
Edric Ellis il 20 Set 2011

0 voti

Do you mean a 'batch job' created using the BATCH function in Parallel Computing Toolbox? If so, then no, the workers executing the batch job will not have access to the memory as they run in a completely separate MATLAB process.
You might wish to check out 'sharedmatrix' from the File Exchange:

1 Commento

rick
rick il 20 Set 2011
That's what I was thinking, however I couldn't find documentation on how separate matlab processes were handled by the memory manager. Unfortunately it seems that at the moment Matlab's pct is only setup for simple parallelism.

Accedi per commentare.

Più risposte (0)

Categorie

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by