Create shared memory for multiple batch files running simultaneously

I am trying to run a tagger through a batch file for different files. This is my code:

String runap1="cd spt1"+"\n"+"java -Xss8192K -Xms128m -Xmx640m -classpath stanford-postagger.jar edu.stanford.nlp.tagger.maxent.MaxentTagger -model models/bidirectional-wsj-0-18.tagger -textFile "+fff[g]+">tag\\"+r1+"\nexit" ; FileWriter fw1 = new FileWriter("ac.bat"); BufferedWriter bw1 = new BufferedWriter(fw1); bw1.write(runap1); bw1.close(); Runtime rx = Runtime.getRuntime(); Process p = null; try { p = rx.exec("cmd.exe /c start ac.bat"); } catch(Exception e) { System.out.println("Error"); } // TODO try { Thread.sleep(15000); } catch (InterruptedException e) { System.out.println("Thread interrupted"); } 

It takes a lot of time, and my computer hangs several times. I want to make shared memory for the tagger, to load it only once and all the batch files will use this shared tagger; they do not have to load tags every time. How can i do this?

+4
source share
1 answer

If you save data in a memory-mapped file, you can load it several times through processes without additional copies. You can even make changes to one process and see what changes are in another.

The problem with this is that you need to work with non-working memory. This works the easiest if the data file is already in binary form, which you can use. those. you do not need to disassemble it.

+1
source

Source: https://habr.com/ru/post/1492444/


All Articles