473,721 Members | 1,825 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Shared Memory Modules

Does any one now if a shared memory module exists, written in python
for a windows platform. I now one exists for unix?
help most appreciated,

S Green
Jul 18 '05 #1
14 24976
S Green wrote:

Does any one now if a shared memory module exists, written in python
for a windows platform. I now one exists for unix?


Your first message with this same question did in fact make it to
Usenet and the mailing list.

Generally speaking, you should allow several days for answers to questions,
rather than getting anxious just because ten people don't jump up and answer
it in the first few hours.

(And my guess is that one doesn't exist, as Windows shared memory would
probably be a completely unreliable bitch, but that's just my guess. :-)

-Peter
Jul 18 '05 #2
st***********@b aesystems.com (S Green) writes:
Does any one now if a shared memory module exists, written in python
for a windows platform. I now one exists for unix?
help most appreciated,

S Green


import mmap

Jul 18 '05 #3
Thomas Heller wrote:

st***********@b aesystems.com (S Green) writes:
Does any one now if a shared memory module exists, written in python
for a windows platform. I now one exists for unix?
help most appreciated,

S Green


import mmap


The docs suggest that mmap.mmap(x, x, mmap.MAP_SHARED ) will work under
Unix but not Windows.

Does the Windows version really support shared memory, or is the
multiple-maps-per-file feature only valid within a single process?

-Peter
Jul 18 '05 #4
Peter Hansen <pe***@engcorp. com> writes:
Thomas Heller wrote:

st***********@b aesystems.com (S Green) writes:
> Does any one now if a shared memory module exists, written in python
> for a windows platform. I now one exists for unix?
>
>
> help most appreciated,
>
> S Green


import mmap


The docs suggest that mmap.mmap(x, x, mmap.MAP_SHARED ) will work under
Unix but not Windows.

Does the Windows version really support shared memory, or is the
multiple-maps-per-file feature only valid within a single process?


Yes, it does. You have to give this memory block a name, though:

sharedmem = mmap.mmap(0, 16384, "GlobalSharedMe mory")

This allows to access 16384 bytes of memory, shared across processes,
not backed up by a file in the filesystem.

Thomas
Jul 18 '05 #5
Thomas Heller wrote:

Peter Hansen <pe***@engcorp. com> writes:
Thomas Heller wrote:

st***********@b aesystems.com (S Green) writes:

> Does any one now if a shared memory module exists, written in python
> for a windows platform. I now one exists for unix?
>
>
> help most appreciated,
>
> S Green

import mmap


The docs suggest that mmap.mmap(x, x, mmap.MAP_SHARED ) will work under
Unix but not Windows.

Does the Windows version really support shared memory, or is the
multiple-maps-per-file feature only valid within a single process?


Yes, it does. You have to give this memory block a name, though:

sharedmem = mmap.mmap(0, 16384, "GlobalSharedMe mory")

This allows to access 16384 bytes of memory, shared across processes,
not backed up by a file in the filesystem.


Thanks, Thomas.

In my opinion the documentation on this is entirely unclear. I attach
it for reference, but I can't offer any suggestions for improvement (as
I don't know anything about shared memory) except that even after reading
it a second time, Thomas' answer above is very much news to me:

'''tagname, if specified and not None, is a string giving a tag name
for the mapping. Windows allows you to have many different mappings
against the same file. If you specify the name of an existing tag,
that tag is opened, otherwise a new tag of this name is created. If
this parameter is omitted or None, the mapping is created without a
name. Avoiding the use of the tag parameter will assist in keeping your
code portable between Unix and Windows. '''

(from http://www.python.org/doc/current/lib/module-mmap.html)

-Peter
Jul 18 '05 #6
Thomas Heller wrote:
Does the Windows version really support shared memory, or is the
multiple-maps-per-file feature only valid within a single process?

Yes, it does. You have to give this memory block a name, though:

sharedmem = mmap.mmap(0, 16384, "GlobalSharedMe mory")

This allows to access 16384 bytes of memory, shared across processes,
not backed up by a file in the filesystem.


That is très cool, it doesn't tell you this in the docs, does it?
The first argument is 'the file handle' of the file to be mapped,
and it doesn't say that 0 is valid and means 'no file at all'...

However, I've just tried it, and managed to crash Python in mmap.pyd
with an application exception... twice. But trying to reproduce it
now fails-- Python keeps running.
I did this:
import mmap
mem=mmap.mmap(0 ,3000000,'irmen ')
mem[0]='a'
mem[2000000]='a'

and initially, it crashed........ . Python 2.3.2 on win xp)

--Irmen

Jul 18 '05 #7
Irmen de Jong <irmen@-NOSPAM-REMOVETHIS-xs4all.nl> writes:
Thomas Heller wrote:
Does the Windows version really support shared memory, or is the
multiple-maps-per-file feature only valid within a single process?

Yes, it does. You have to give this memory block a name, though:
sharedmem = mmap.mmap(0, 16384, "GlobalSharedMe mory")
This allows to access 16384 bytes of memory, shared across processes,
not backed up by a file in the filesystem.


That is très cool, it doesn't tell you this in the docs, does it?
The first argument is 'the file handle' of the file to be mapped,
and it doesn't say that 0 is valid and means 'no file at all'...

However, I've just tried it, and managed to crash Python in mmap.pyd
with an application exception... twice. But trying to reproduce it
now fails-- Python keeps running.
I did this:
>>> import mmap
>>> mem=mmap.mmap(0 ,3000000,'irmen ')
>>> mem[0]='a'
>>> mem[2000000]='a'

and initially, it crashed........ . Python 2.3.2 on win xp)


This works for me even from the beginning (with 2.3 CVS version, XP Pro).

Understading which parameters to pass apparently requires

- reading the mmapmodule.c sources
- and reading about CreateFileMappi ng and MapViewOfFile in MSDN.

It would be great if someine could submit a patch for the docs <wink>.

I vaguely remember, but am not able to find it anymore: didn't AMK once
had an article about this somewhere?

Thomas
Jul 18 '05 #8
Irmen de Jong wrote:
However, I've just tried it, and managed to crash Python in mmap.pyd
with an application exception... twice. But trying to reproduce it
now fails-- Python keeps running.
I did this:
>>> import mmap
>>> mem=mmap.mmap(0 ,3000000,'irmen ')
>>> mem[0]='a'
>>> mem[2000000]='a'

and initially, it crashed........ . Python 2.3.2 on win xp)
--Irmen


Probably not enough actual memory hanging around. Some systems
(and from this I'd guess XP) allocate virtual memory by reserving
address space, not actually allocating the RAM and/or backing
store for that memory. Python has no control over this, and you
have nothing good to do if the memory is over-allocated. When
you create the memory, you could walk across it writing into it
(forcing it to exist), but that would just force the failure to
happen earlier.
-Scott David Daniels
Sc***********@A cm.Org

Jul 18 '05 #9
Scott David Daniels wrote:
Irmen de Jong wrote:
However, I've just tried it, and managed to crash Python in mmap.pyd
with an application exception... twice. But trying to reproduce it
now fails-- Python keeps running.
I did this:
>>> import mmap
>>> mem=mmap.mmap(0 ,3000000,'irmen ')
>>> mem[0]='a'
>>> mem[2000000]='a'

and initially, it crashed........ . Python 2.3.2 on win xp)
--Irmen

Probably not enough actual memory hanging around. Some systems
(and from this I'd guess XP) allocate virtual memory by reserving
address space, not actually allocating the RAM and/or backing
store for that memory.


Over-commit is that called, right?
I'm sorry but that certainly wasn't the case here.
My machine has 512 Mb RAM and about 250 Mb of them
allocated when I tried it. (physical RAM that is)

Very weird, I cannot reproduce the initial crash I experienced.

--Irmen

Jul 18 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
4406
by: Srijit Kumar Bhadra | last post by:
Hello, Here is some sample code with pywin32 build 203 and ctypes 0.9.6. Best regards, /Srijit File: SharedMemCreate_Mutex_win32all.py # This application should be used with SharedMemAccess_Mutex_ctypes.py or SharedMemAccess_Mutex_win32all.py
3
2143
by: alanrn | last post by:
I would like to start a dialog on how to implement the equivalent functionality of UNIX shared memory in .NET. I work with a factory automation system. The bulk of the system is written in C/C++. It was ported from UNIX to run under Windows using .NET. If for no other reason than as an educational exercise, I have been wondering what it would take to rewrite the system under C#. The system currently has about a 100K “shared...
11
4900
by: Michael Schuler | last post by:
The use of STL in shared memory poses a real problem since (non-smart) pointers are not allowed there. Is there any solution for containers in shared memory using smart pointers? Where can I find templates?
1
2115
by: myren, lord | last post by:
When I first discovered shared memory (between multiple processes) I immediately started thinking of how to build my own VM subsystem + locking mechanisms for a large single block of memory. This seems like one option, the other appears to be just having each "object" you want to share be a shared mem space to itself: allocate objects into a defined shared mem space. But here you have many many objects being shared. Having a VM...
14
8210
by: phil_gg04 | last post by:
Dear C++ Experts, Over the last couple of months I have been writing my first program using shared memory. It has been something of an "in-at-the-deep-end" experience, to say the least. At present the shared memory contains a few fixed-size structs, but I really need to be able to store more complex variable-sized data in there. So the next task is to work out how to store C++ objects, and if possible STL containers, in this shared...
12
5542
by: Jeremy | last post by:
Hi all, I'm getting very confused about how DB2 uses shared memory and I wonder if someone could clarify matters for me, please ? We are running 32bit DB2 V7.2 FP9 under AIX 4.3.3 on a machine with 64 Gb of memory with a single non-partitioned database using extended storage and with intra-parallelism enabled. I've been experimenting with changing various parameters in an attempt
5
7079
by: Jim | last post by:
Hello, I have a broken server that we are going to be moving off to a new server with a new version of DB2 but here is what I have right now: RedHat 7.0 (2.2.24smp) DB2 v6.1.0.40 I am getting this error when I try to run the command 'db2 "backup database dbname online to /opt/BACKUP"' on my 3 databases: SQL1042C An unexpected system error occurred. SQLSTATE=58004
2
1629
by: Sebastjan Trepca | last post by:
Hey! Are there any "live" modules for working with shared memory in Python? I found some but they are all dead(posh,shm)... Thanks, Sebastjan
4
3117
by: herbert | last post by:
I am coding a dozen "background" realtime apps for factory automation in .NET 2.0. The apps need to share a common memory as there are lots of variables to be shared (and synchronized of course). I need distinct apps for reasons like user interaction/access rights, error compartments, and because the size of the code, access to various ports, ... In the end the apps should run as Windows Service(s).
0
8844
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
9132
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9067
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8009
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6672
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4487
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3191
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2578
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2132
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.