shared memory pointer

Tim Golden mail at timgolden.me.uk
Tue Sep 11 10:52:19 EDT 2007


Tim wrote:
> I think I want to stay away from mmap because it uses the disk to
> store my memory. 

My point is that, whatever mmap is doing, your own code
is doing *exactly the same thing*. Passing the
INVALID_HANDLE_VALUE as both your code and the mmap
code are doing is documented as producing an area of
memory backed by the page file (which, let's face it,
is what all of your memory is backed by). Whether that's
good enough for you or not I don't know, but you're not
going to get any better with *this* technique :)

[... snip explanation of C++ simulator and Python charting ...]

OK, so your C++ stuff dumps to memory. Using CreateFileMapping
and MapViewOfFile? Or some other kind of global memory?

In short, if your C++ can write stuff out to shared memory
created using CreateFileMapping/MapViewOfFile with a first
param of INVALID_HANDLE_VALUE and a tag name, you can use
Python's mmap with the equivalent values and tag name to
access that data. Straightforward.

If, on the other hand, your C++ is writing to arbitrary
global memory, I don't think it's going to fly. You could
also use named pipes, by the way, and possibly other
Windows synching mechanisms. (He says, muddying the waters
horribly).

TJG



More information about the Python-list mailing list