I am writing a program in C#. First, it reads a large file into a dictionary variable, then the variable is used as a search table to process other data (saved in another file). I would like to execute multiple instances of the program to process a lot of files simultaneously. The problem is I don't have enough memory to execute many instances simultaneously, since each instance of the program has to read the large file first.
I was wondering if there is a way to share the dictionary variable across all the instances. The program only required to read the large file into memory once, and then all the instances of the same program could access the shared variable. It could save a lot of time by skipping reading the file repeatedly, and a lot of memories since there is only one shared dictionary holding the data.
Using a database is an option, but requires database installation on the target system.
The dictionary I want to share is: Dictionary<string, (char, char)> searchTable = new(); Dictionary<string, Person> searchPersonTable = new();
So, if there is an easy way to share the dictionary variable, how to implement it?
MORE: The files that need to be processed are not coming all at once (only several at a time), so I cannot use multi-threads to process all of them all at once.