From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem Creating File Mapping Object in Memory Mapped FIles

Solved!
Go to solution

I'm actually working on Image processing and things.
I have written a labVIEW code that pass image from LabVIEW to Python via TCP/IP socket communication, but the time overhead is very high for a big files.
So,I searched through the NI forums and found Memory Mapped Files are the best way to do Inter Process Communication(IPC) from here : https://forums.ni.com/t5/Developer-Center-Resources/Inter-Application-Communication/ta-p/3523015  .
and I also found a LV code for Memory Mapped File here: https://forums.ni.com/t5/LabVIEW/memory-mapped-file-access-problem/m-p/1213533 . But,it's not working. Create new Memory Mapped File always returns NULL. I also attached the code below

 

Any help?.

Thanks in advance.

 

0 Kudos
Message 1 of 4
(3,860 Views)

The example works on my computer. However this library is specifically only 32 bit programmed and would require some work to make it work in 64 bit LabVIEW.

 

As to TCP/IP being slow when communicating through localhost, I'm not sure you will see huge improvements through memory mapping. Because when operating between localhost endpoints the Winsock library actually uses internally memory mapping too. But of course it needs to do some synchronizing between the two sides so that the read side doesn't try to read while the write side is updating the memory.

 

And you will have to do something like that too somehow. So while memory mapping may seem like the golden egg for fast sharing of contents between processes, some of the performance will be eaten away by the necessary synchronization through mutexes or similar in order to guarantee consistent memory states on both sides. 

Rolf Kalbermatter
My Blog
0 Kudos
Message 2 of 4
(3,816 Views)
Solution
Accepted by topic author Prabsun

This is my 64 bit safe version of the above library. I chose to implement the thing a little differently with VIs wrapping the individual Call Library Nodes properly.

It is not really what I would call a production ripe implementations with things like the handles and the mapped pointers all being simple 64 bit integers. While they can be connected to each other, doing so will surely result in VERY BAD THINGS happening. So tread lightly when using this version, wear your safety belts and safety googles and think carefully before you hit the run button with any program you used these functions in.

The proper way to implement this would be as LabVIEW classes, wrapping the memory map handle and the actual memory pointer into individual classes, so they CAN"T be wired together accidentally.

Rolf Kalbermatter
My Blog
Message 3 of 4
(3,804 Views)

I Want to do the labview and unity software communication through map files. I used WIN Memory Map.llb. This is working fine for the 1D array of Unsigned 8 bit integer. But i want to use the 3 different data types in the same project. So in WIN MMAP,lvlib write, i tried to change the data type.It is showing an error. 

Could you please help for the same?

0 Kudos
Message 4 of 4
(2,570 Views)