Java: 1.6
OS: Win XP
I have been having an issue with a scheduled task i made that kicks off a java program i created. The issue is that the program uses large chucks of data which is causing the program to seize up mid way.
I went ahead and split the program up into different sections so they do not have to run all at once but Im unsure how to build my .cmd file for the scheduled task. I need it to run each piece and after each piece, kill java / run garbage collection and then run the next task.
Original piece:
java -jar CommandLine.jar -f p d pr d dr d e d qp d ea d pa d pb d as d ndp d g d sc d 2> ErrorLog\cmdErrorLog.txt
Each piece is represented by p d, or pr d.
So would something like this actually stop java? (testing is hard cause im running on live data sets that get effected when ran):
java -jar CommandLine.jar -f pr d 2> ErrorLog\cmdErrorLog.txt
java -jar CommandLine.jar -f dr d 2> ErrorLog\cmdErrorLog.txt
java -jar CommandLine.jar -f e d 2> ErrorLog\cmdErrorLog.txt
java -jar CommandLine.jar -f qp d 2> ErrorLog\cmdErrorLog.txt
java -jar CommandLine.jar -f ea d 2> ErrorLog\cmdErrorLog.txt
java -jar CommandLine.jar -f pa d 2> ErrorLog\cmdErrorLog.txt
java -jar CommandLine.jar -f pb d 2> ErrorLog\cmdErrorLog.txt
java -jar CommandLine.jar -f as d 2> ErrorLog\cmdErrorLog.txt
java -jar CommandLine.jar -f ndp d 2> ErrorLog\cmdErrorLog.txt
java -jar CommandLine.jar -f g d 2> ErrorLog\cmdErrorLog.txt
java -jar CommandLine.jar -f sc d 2> ErrorLog\cmdErrorLog.txt
Or is there a better way to kill java between each piece? I really just need the memory cleared and java restarted.
Also Note that I have given Java as much memory as i can on the box it is running off of.
Any help would be insight or help would be greatful.
Thanks!
Each execution of Java represents a new and self-contained JVM. So executing multiple times will obviously work to completely relinquish all memory before the next instance is started.
If you can easily modify the CommandLine program though, then a more efficient approach would be to use Main method to split the work up within the same process. It could basically do exactly what you are doing with the multiple JVM executions, but without having to stop/start new a JVM each time. That does mean that the program would need to be written correctly to relinquish all resources on each iteration though so that the garabage collector could do its job.