[Win32utils-devel] Need some help with latest win32-mmap
johan.nilsson at esrange.ssc.se
Tue Oct 10 02:51:29 EDT 2006
> -----Original Message-----
> From: win32utils-devel-bounces at rubyforge.org
> [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of
> Daniel Berger
> Sent: den 6 oktober 2006 22:03
> To: win32utils-devel at rubyforge.org
> Subject: [Win32utils-devel] Need some help with latest win32-mmap
> Hi all,
> I've got the latest win32-mmap code checked into CVS.
> Unfortunately, it seems that I'm not able to open an existing
> mapping and retrieve set data. Below is a simple example
> that seems like it ought to work but doesn't. Any ideas?
> # map1.rb
> require 'win32/mmap'
> include Win32
> mmap = MMap.new(:name => 'alpha', :size => 20) p mmap.address
> mmap.test = "hello"
> # map2.rb
> # mmap = MMap.open('alpha') # Boom!
> mmap = MMap.new(:name => 'alpha', :size => 20) # Ok so far...
> p mmap.test # Boom!
> I tried using MMap.open and MMap.new. Neither seems to work
> as expected. What am I doing wrong?
I haven't checked the implementation and this is probably too obvious to
be the culprit, but:
If map1.rb runs to completion and closes the mmap before map2.rb can
attach by opening it, the memory map won't exist unless you are using
something else than the paging file as backing storage. The Win32 mmaps
are reference counted through their handles as pretty much everything
Also, as you can see it that using MMap.new from map2.rb works as the
first step, but as this only creates a new identically named mmap there
is no 'test' data there. Hence the 'boom' I'd guess.
More information about the win32utils-devel