473,657 Members | 2,507 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Shared memory in .NET and WCF

Hello,

I have to share a object in RAM between several processes. I intend to
design a special process to load this objet (an Autocad plan) in memory, and
to take care of the read/write operations made by the other processes with
WCF based on named pipes.

Would you think it is a good idea ?

Best regards

Oriane

Jun 5 '07 #1
10 3966
Hello Oriane,

so, as I understand it's like the caching, right?

I see no evil in this. The similiar approach is used widely in win32 world
and names MMF.
You only need to worry about thread safing when accessing your object.

---
WBR, Michael Nemtsev [.NET/C# MVP].
My blog: http://spaces.live.com/laflour
Team blog: http://devkids.blogspot.com/

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo

OHello,
O>
OI have to share a object in RAM between several processes. I intend
Oto design a special process to load this objet (an Autocad plan) in
Omemory, and to take care of the read/write operations made by the
Oother processes with WCF based on named pipes.
O>
OWould you think it is a good idea ?
O>
OBest regards
O>
OOriane
O>
Jun 5 '07 #2
"Oriane" <or****@guerman tes.frwrote in message
news:10******** *************** ***********@mic rosoft.com...
Hello,

I have to share a object in RAM between several processes. I intend to
design a special process to load this objet (an Autocad plan) in memory,
and to take care of the read/write operations made by the other processes
with WCF based on named pipes.

Would you think it is a good idea ?

Best regards

Oriane

Not sure what you mean here, "Named pipes" and "shared memory" are different
beasts! Named pipes are not wrapped by the Framework, so you will have to
use PInvoke to call the native shared memory API's. WCF offers remoting
features over named pipes, , these 'Pipe' channels are actually mapped over
shared memory files, this is by far the fastest way to share data across
processes.

Willy.
Jun 5 '07 #3
Using common data between processes via shared memory is a fairly common
thing to do. It can be very difficult to get right if this is your first
attempt. Things like concurrency are hard to get right. Also be advised
that accessing data via pointers can also be difficult. If you are
dealing with a large shared pool it might get hard to find memory in
every process that maps to the exact same address. In our case the
entire pool can be mapped where ever the OS puts it within the process
and all pointer types within the pool are actually offsets. The
applications computer the pointers on the fly by adding the offset to
start of the pool. If you are dealing with small pools this probably
won't be a problem. Memory compaction can be another problem. If you
allocate and deallocate objects in your pool it can get fragmented.
Dealing with this fragmentation can get tricky for a novice. It took
me a couple of years to get our shared memory real time database right.

Hope this helps.
Leon Lambert
Oriane wrote:
Hello,

I have to share a object in RAM between several processes. I intend to
design a special process to load this objet (an Autocad plan) in memory,
and to take care of the read/write operations made by the other
processes with WCF based on named pipes.

Would you think it is a good idea ?

Best regards

Oriane
Jun 5 '07 #4

"Leon Lambert" <la******@inil. coma écrit dans le message de
news:OM******** ******@TK2MSFTN GP02.phx.gbl...
Using common data between processes via shared memory is a fairly common
thing to do. It can be very difficult to get right if this is your first
attempt. Things like concurrency are hard to get right. Also be advised
[...].
Dealing with this fragmentation can get tricky for a novice. It took
me a couple of years to get our shared memory real time database right.
Yes that's exactly why I prefer to use WCF !!!!

Regards

Jun 5 '07 #5
Hello Willy,

"Willy Denoyette [MVP]" <wi************ *@telenet.bea écrit dans le message
de news:95******** *************** ***********@mic rosoft.com...
>
Not sure what you mean here, "Named pipes" and "shared memory" are
different beasts! Named pipes are not wrapped by the Framework, so you
will have to use PInvoke to call the native shared memory API's. WCF
offers remoting features over named pipes, , these 'Pipe' channels are
actually mapped over shared memory files, this is by far the fastest way
to share data across processes.
Yes I don't want to get involved into shared memory problems, since I have
no experience about that on Windows. I really prefer to use WCF over named
pipes. If this is the fastest way to shared data across processes, it is
just perfect...

Thanks

Jun 5 '07 #6
Hello Michael,

"Michael Nemtsev" <ne*****@msn.co ma écrit dans le message de
news:a2******** *************** ****@msnews.mic rosoft.com...
Hello Oriane,

so, as I understand it's like the caching, right?

I see no evil in this. The similiar approach is used widely in win32 world
and names MMF.
You only need to worry about thread safing when accessing your object.
Ok fine !

Thanks

Jun 5 '07 #7
On Jun 5, 3:02 am, "Oriane" <ori...@guerman tes.frwrote:
Hello,

I have to share a object in RAM between several processes. I intend to
design a special process to load this objet (an Autocad plan) in memory, and
to take care of the read/write operations made by the other processes with
WCF based on named pipes.

Would you think it is a good idea ?

Best regards

Oriane

Just to clarify, are you thinking of exposing this object via pointers
and shared memory and allow some one to have direct access to its data
from another process, or provide high-level read/write methods that
provides a data access layer to the data (e.g. GetXXX(), GetYYY()) ?

If pointers and shared memory, then this is a more complex area and
WCF doesn't do much for you in this area (in my opinion).

It sounds like you are going to be running this on the same computer
as the other processes, correct? If providing high-level methods,
you may look at .NET Remoting (http://www.developer.com/net/cplus/
article.php/1479761) this may provide a better method of sharing data
and objects across processes on the same computer than WCF.

Ron

Jun 5 '07 #8

<ro************ *@yahoo.coma écrit dans le message de
news:11******** **************@ h2g2000hsg.goog legroups.com...
>
Just to clarify, are you thinking of exposing this object via pointers
and shared memory and allow some one to have direct access to its data
from another process, or provide high-level read/write methods that
provides a data access layer to the data (e.g. GetXXX(), GetYYY()) ?
I do not intend to use shared memory. An ad hoc process will load the "data"
into its heap, and implement high-level read/write methods, with of course
some locks...
>
If pointers and shared memory, then this is a more complex area and
WCF doesn't do much for you in this area (in my opinion).
Absolutely.
It sounds like you are going to be running this on the same computer
as the other processes, correct?
yes
If providing high-level methods, you may look at .NET Remoting
(http://www.developer.com/net/cplus/
article.php/1479761) this may provide a better method of sharing data
and objects across processes on the same computer than WCF.
I thought that WCF was a superset of remoting, an that what remoting can do,
so can WCF ?
Ron
Oriane

Jun 5 '07 #9
On Jun 5, 9:11 am, "Oriane" <ori...@guerman tes.frwrote:
<ronscottlang.. .@yahoo.coma écrit dans le message denews:11****** *************** *@h2g2000hsg.go oglegroups.com. ..
Just to clarify, are you thinking of exposing this object via pointers
and shared memory and allow some one to have direct access to its data
from another process, or provide high-level read/write methods that
provides a data access layer to the data (e.g. GetXXX(), GetYYY()) ?

I do not intend to use shared memory. An ad hoc process will load the "data"
into its heap, and implement high-level read/write methods, with of course
some locks...
If pointers and shared memory, then this is a more complex area and
WCF doesn't do much for you in this area (in my opinion).

Absolutely.
It sounds like you are going to be running this on the same computer
as the other processes, correct?

yes
If providing high-level methods, you may look at .NET Remoting
(http://www.developer.com/net/cplus/
article.php/1479761) this may provide a better method of sharing data
and objects across processes on the same computer than WCF.

I thought that WCF was a superset of remoting, an that what remoting can do,
so can WCF ?
Ron

Oriane
You may be right, just wanted to bring it up as an option. I was
thinking that .NET Remoting may be more friendly regarding CLR types,
state management, and callbacks, but WCF is certainly an improvement
in these areas over ASMX web services. Just may require a little more
configuration to get this all working if needed. I was thinking
that .NET Remoting may be little faster since it uses binary encoding,
but from the link below it looks like I am wrong. If you are using
the TCP, Named Pipes, etc. (anything other than HTTP), then I think
you will get binary encoding by default

http://msdn2.microsoft.com/en-us/library/bb310550.aspx

Ron

Jun 5 '07 #10

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

Similar topics

0
4394
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
2135
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
4881
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
2112
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
8205
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
5531
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
7069
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
4
3104
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).
21
8373
by: llothar | last post by:
Hello, i need to manage a heap in shared memory. Does anybody know about a portable (win32+mac+posix) c implementation for this.
5
587
by: Sune | last post by:
Hi all, I want to make data stored in-memory (not disk) available to several processes. My concern is that poorly written C applications with dangling pointers may(will) damage the data in this memory segment if it is open to all, i.e. shared memory mapped into all processes memory area. I don't want to use TCP/IP client/server between the apps and a data store process due to the overhead.
0
8326
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8743
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8522
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
7355
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...
0
5647
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4173
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...
0
4333
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1973
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1736
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.