Results 1 to 10 of 10
Thread: Runing delay of my Program
- 02-15-2013, 11:28 PM #1
Member
- Join Date
- Aug 2011
- Posts
- 56
- Rep Power
- 0
Runing delay of my Program
Hello
I have a strategy board game created with Java, apart from two agents an they uses a Neural network for the next move and some txt files for the logs.
I create some other classes witch they create a tournament of round robin scheduling with many players and thousand repeats of the game per round.
The problem becomes after many repeats of the game, it goes slowly and slowly and slowly as a result not to finish never.
In example, i have 100 players with 10 games per Round. This means 990 games for each agent and totally 99000 games for all the tournament.
After approximately 500 games, the programs goes slowly ans slowly.
How i can find where is the problem ???? is any tool or algorithm that can tell me where the program stuck.
I use NetBeans can help me someone with this problem .
Thank you in advanced.
- 02-16-2013, 12:55 AM #2
Re: Runing delay of my Program
You could use a tool like JConsole or the eclipse memory analyzer (or whatever its equivalent in netbeans is): Eclipse Memory Analyzer Open Source Project
Or you could just do it the old fashioned way with print statements and the debugger. It sounds like you're either filling up a data structure and running out of memory, or running an algorithm that takes a long time to complete. Without seeing an SSCCE I'm completely guessing.How to Ask Questions the Smart Way
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
- 02-16-2013, 10:21 AM #3
Member
- Join Date
- Aug 2011
- Posts
- 56
- Rep Power
- 0
Re: Runing delay of my Program
I will try to use that tools . when you say "Running out of memory " you mean RAM of my pc ?? Because i have 8GB an never goes more that 6GB during the program running.
- 02-16-2013, 04:03 PM #4
Re: Runing delay of my Program
How to Ask Questions the Smart Way
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
- 02-16-2013, 04:24 PM #5
Member
- Join Date
- Aug 2011
- Posts
- 56
- Rep Power
- 0
Re: Runing delay of my Program
I don't know have to configure it.
- 02-16-2013, 04:29 PM #6
Re: Runing delay of my Program
How to Ask Questions the Smart Way
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
- 02-20-2013, 06:10 PM #7
Member
- Join Date
- Aug 2011
- Posts
- 56
- Rep Power
- 0
Re: Runing delay of my Program
Thank you very much about your instructions .
But now i have another question about the multi threading in java
Like i told in the beginning of this Thread i Have a Strategy board Game in Java with many repeats. I run it with the next code.
RunGame.java
Common.javaJava Code:public class RunGame implements Common{ public static void runTheGame(int a, int b) throws IOException{ int TournamentRounds = a; int GameofRound = b; int gamesNumber = 2; for (int i=0;i<gamesNumber;i++){ Spy myGame=new Spy(DIMBOARD,DIMBASE,NUMOFPAWNS); } public static RunGame (){ for (int TournamentRounds1 = 0; TournamentRounds1 < 10 ; TournamentRounds1++) { for ( GameofRound1 = 0; GameofRound1 < 10; GameofRound1++) { runTheGame(TournamentRounds1, GameofRound1); } } }
Spy.javaJava Code:interface Common{ static final int DIMBOARD=10; static final int DIMBASE= 2; static final int NUMOFPAWNS= 10; }
/////////////////////////////////The new Class with the MultiThreading////////////////////////////Java Code:public class Spy { // Here play the game computer vs computer // From this class begins many other classes and method with their contents }
newRunGame.java
Java Code:public class RunGame implements Common{ public static void runTheGame(int a, int b) throws IOException{ int TournamentRounds = a; int GameofRound = b; int gamesNumber = 2; for (int i=0;i<gamesNumber;i++){ Spyl myGame=new Spy(DIMBOARD,DIMBASE,NUMOFPAWNS); } public static RunGame (){ for (int TournamentRounds1 = 0; TournamentRounds1 < 10 ; TournamentRounds1++) { newThread myThread[] = new newThread[10]; for ( GameofRound1 = 0; GameofRound1 < 10; GameofRound1++) { myThread[GameofRound] = new newThread(); myThread[GameofRound].newThread2("Threat#",TournamentRounds, GameofRound); myThread[GameofRound].start(); } } static class newThread extends Thread{ public static int TournamentRounds,GameofRound; public final static int THREADPASS = 0; public final static int THREADFAIL = 1; static int _status; public static String nameThread = ""; public newThread () { _status = THREADFAIL; } public static void newThread2 (String s, int a ,int b) { nameThread = s; TournamentRounds=a; GameofRound=b; _status = THREADFAIL; } public int status() { return _status; } public void run() { try { newRunGame.runGame(TournamentRounds, GameofRound); } catch (IOException ex) { Logger.getLogger(RunRLGTournament.class.getName()).log(Level.SEVERE, null, ex); } _status = THREADPASS; } } }
Because the game was to slow, i try to implement it with multi-Treading and i create the newRunGame.java.
The problem with the changing of the class RunGame.java with the newRunGame.java is that after the game starts it returns many error like the next from many other classes where they are called from the Spy.java class.
In the x in a number.
Exception in thread "Thread-x" java.lang.NullPointerException
Exception in thread "Thread-x" java.lang.NullPointerException
Exception in thread "Thread-x" java.lang.NullPointerException
Before i create the new class i did not had this kind of error.
Any idea ???????????????
Thank you in Advanced
- 02-20-2013, 06:49 PM #8
Re: Runing delay of my Program
I do not think that multithreading is going to fix your original problem, and I don't think it's directly related to your new problem. Favor simplicity over needless complication.
I recommend creating a single-threaded SSCCE that demonstrates the original problem. Not that this is not your complete game, just a runnable example that's enough to get an idea of what's going on. Without it, we're completely guessing.How to Ask Questions the Smart Way
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
- 02-20-2013, 07:59 PM #9
Member
- Join Date
- Aug 2011
- Posts
- 56
- Rep Power
- 0
Re: Runing delay of my Program
Why will not fix my problem. If have 100 games with 10 threads the program will finish faster. With a single thread and SSCCE i have my first program the RunGame, Which run slowly but clearly correct. The slowness comes from the NN like i found the previous days. As the NN grows the software goes slowly,for now i cant find any solution about the NN. But i think by running many games together the program will finish faster, is that correct ???
Yes this code is not the full game, i did not upload it due to the big amount of the classes. But as a example is correct.
I would like to ask you a question about the above code.
When i run the newRunGame.java in the for loop where i create threads with the (myThread[GameofRound] = new newThread();), each thread call autonomous the class and the method runTheGame ???
If have variables with static public declaration that will cause the above problem ???
- 03-02-2013, 11:08 AM #10
Member
- Join Date
- Aug 2011
- Posts
- 56
- Rep Power
- 0
Re: Runing delay of my Program
Hello i am here again.
I try to increase the memory of my java but like i can see, it is not increased.

Like you can see in the next image the limited memory is still 1.8 GB. Why ??

And one more question is there any way to clear all the used memory, from java, in the end of the for loop in order the next loop to begin with clear memory ??
I try the System.gc(); , but i didnt get any changes.
Thank you again
Cha.
Similar Threads
-
Runing .exe from Java
By Java_B in forum New To JavaReplies: 8Last Post: 11-17-2011, 04:15 PM -
runing Java program increases continuing memory usage
By henry123 in forum Advanced JavaReplies: 12Last Post: 02-25-2011, 02:09 PM -
calculating time of program runing
By sara12345 in forum New To JavaReplies: 3Last Post: 03-17-2010, 12:25 AM -
Trouble in Runing
By kavithaprabhaker in forum New To JavaReplies: 5Last Post: 05-13-2008, 05:59 AM -
How to write a JAVA program to mesure ping delay..?
By sacr83 in forum NetworkingReplies: 1Last Post: 02-15-2008, 04:07 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks