Re: Interprocess Communication & Performance



I guess the first question is how are you going to structure this and how
much data is passing through. For instance if the data items are small and
there is a need for a notification (such as an event) then forget the shared
memory the performance hit from the synchronization will overwhelm things.

There is no "general purpose answer" here without having details of the data
items, the frequency and the synchronization requirements, you are just
guessing.


--
Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
Remove StopSpam from the email to reply



"Jos Scherders" <thrower@xxxxxxx> wrote in message
news:egGkKZiRGHA.5296@xxxxxxxxxxxxxxxxxxxxxxx
Hi,

In my hypothetical solution I am also avoiding memcpy's because I want
to map the allocated memory in both processes. So there would be no more
memcpy's then using shared file mapping I think. I am however avoiding any
disk IO because of swapping.

It would be interesting to know what others people have done if
performance
is paramount.

Jos.

"Skywing" <skywing_NO_SPAM_@xxxxxxxxxxxxxxxxxxx> wrote in message
news:ugs0ILiRGHA.336@xxxxxxxxxxxxxxxxxxxxxxx
I would go for a shared file mapping - you eliminate lots of memcpy's that
way.

(Just because it is "pagefile backed" doesn't mean that it will be
continually paged out - think of it like any other VM you allocate, which
might be paged out if the system is under memory pressure or it becomes
unused for an extended period of time.)

"Jos Scherders" <thrower@xxxxxxx> wrote in message
news:%23y%23%230ohRGHA.5908@xxxxxxxxxxxxxxxxxxxxxxx
Hi,

I know these API's, they are all documented in
MSDN, but that does not answer the question.
The question is, is allocating and mapping
allocated memory myself faster then using the
file mapping stuf or is not worth the trouble. My
thought was that avoiding flushing memory to the
swap file and reading it back could be avoided and
therefore would be faster.

Any idea's ?

Jos.

"Kellie Fitton" <KELLIEFITTON@xxxxxxxxx> wrote in message
news:1142119554.874839.157820@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi,

Use the following APIs to allocate memory in the address space
of another process:

VirtualAllocEx()
VirtualFreeEx()

Additionally, you can use he following APIs to create shared
memory in IPC:

CreateFileMapping()
OpenFileMapping()
MapViewOfFileEx()
UnmapViewOfFile()
FlushViewOfFile()

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/memory/base/virtualallocex.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/memory/base/virtualfreeex.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/fs/createfilemapping.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/fs/openfilemapping.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/fs/mapviewoffileex.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/fs/unmapviewoffile.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/fs/flushviewoffile.asp

Hope these suggestions helps,

Kellie.









.



Relevant Pages

  • Re: Interprocess Communication & Performance
    ... I would go for a shared file mapping - you eliminate lots of memcpy's that ... might be paged out if the system is under memory pressure or it becomes ... allocated memory myself faster then using the ... file mapping stuf or is not worth the trouble. ...
    (microsoft.public.win32.programmer.kernel)
  • Re: How to take in a string of any size?
    ... >the contents into the allocated memory. ... nobody said the string started at the beginning of the file. ... >number of calls to realloc() isn't going to be excessive). ...
    (comp.lang.c)
  • Re: will I get Memory leak..
    ... dynamically assigned memory area will i get memory leak.. ... The problem with your code, on the other hand, is that your call to strcpywrites a null character to fp, which is one position past the end of the allocated memory. ... As a result of that error, the behavior of your entire program is undefined, which means that anything could go wrong A memory leak is very definitely a possibility from making that kind of mistake, but most of the other possible consequences of that mistake are much worse than memory leaks. ...
    (comp.lang.c)
  • Re: similar Perl data structure?
    ... One big difference between the two versions is the user of your C function has to remember to free all the allocated memory. ... Memory is just one of the resources a programme has to manage. ... Using platform specifics (file mapping) probably yes. ...
    (comp.lang.c)
  • Re: Memory leak when internal pointer passed out as parameter
    ... new block of memory when foo1 returns. ... within foo1 will remain in the system heap forever. ... The allocated memory will be returned to the system heap when the ... free the memory when the program exits, ...
    (comp.lang.c)