Search code examples
c#listglobal-variablessystem-variable

Does a System Wide Global List variable exist


I have a 3 Dimensional List like this:
List<List<List<Vector128<byte>>>> dimensionLIST = new List<List<List<Vector128<byte>>>>();

Now, when I fill this List with the data I use for calculations, it will take up 20 GB of RAM memory.

The calculations that I do take 10 hours. So I have created a solution where I open up 10 instances of the application, where I have divided the work in 10 pieces which will make the calculation to only take 1 hour (I have 24 cores in the computer)

The problem now, is that each instance of the Form Application will need to read in this dimensionLIST which means that this would take up 20 GB * 10 = 200 GB RAM which is just not a solution.

My question is, if there is any possibility to put this dimensionLIST in some kind of System Wide Global List variable, - which can be accessed by all 10 instances?

(To mention is that I can't divide this dimensionLIST in 10 pieces because each instance actually needs the whole list)

Thank you!


Solution

  • You can use Named Pipes.

    A named pipe is a named, one-way or duplex pipe for communication between the pipe server and one or more pipe clients. All instances of a named pipe share the same pipe name, but each instance has its own buffers and handles, and provides a separate conduit for client/server communication. The use of instances enables multiple pipe clients to use the same named pipe simultaneously. Any process can access named pipes, subject to security checks, making named pipes an easy form of communication between related or unrelated processes.

    ALTERNATIVELY

    Use a Windows File Mapping Object which allows you to share memory between processes.

    As mentioned in a comment Memory Mapped Files could be a viable option