Results 1 to 10 of 10
  1. #1
    ki_ha1984 is offline Member
    Join Date
    Aug 2011
    Posts
    74
    Rep Power
    0

    Default 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.

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,958
    Rep Power
    8

    Default 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!

  3. #3
    ki_ha1984 is offline Member
    Join Date
    Aug 2011
    Posts
    74
    Rep Power
    0

    Default 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.

  4. #4
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,958
    Rep Power
    8

    Default Re: Runing delay of my Program

    Quote Originally Posted by ki_ha1984 View Post
    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.
    And how much of that memory are you giving to the JVM? By default it doesn't take all of it.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  5. #5
    ki_ha1984 is offline Member
    Join Date
    Aug 2011
    Posts
    74
    Rep Power
    0

    Default Re: Runing delay of my Program

    I don't know have to configure it.

  6. #6
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,958
    Rep Power
    8

    Default 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!

  7. #7
    ki_ha1984 is offline Member
    Join Date
    Aug 2011
    Posts
    74
    Rep Power
    0

    Default 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
    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++){
               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);
                                }
                    }
    }
    Common.java
    Java Code:
    interface Common{
       static final int DIMBOARD=10;
       static final int DIMBASE= 2;
       static final int NUMOFPAWNS= 10;
    }
    Spy.java
    Java Code:
    public class Spy {
    // Here play the game computer vs computer
    // From this class begins many other classes and method with their contents
    }
    /////////////////////////////////The new Class with the MultiThreading////////////////////////////
    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

  8. #8
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,958
    Rep Power
    8

    Default 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!

  9. #9
    ki_ha1984 is offline Member
    Join Date
    Aug 2011
    Posts
    74
    Rep Power
    0

    Default 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 ???

  10. #10
    ki_ha1984 is offline Member
    Join Date
    Aug 2011
    Posts
    74
    Rep Power
    0

    Default 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.

    Runing delay of my Program-1.png

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

    Runing delay of my Program-2.png

    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

  1. Runing .exe from Java
    By Java_B in forum New To Java
    Replies: 8
    Last Post: 11-17-2011, 04:15 PM
  2. runing Java program increases continuing memory usage
    By henry123 in forum Advanced Java
    Replies: 12
    Last Post: 02-25-2011, 02:09 PM
  3. calculating time of program runing
    By sara12345 in forum New To Java
    Replies: 3
    Last Post: 03-17-2010, 12:25 AM
  4. Trouble in Runing
    By kavithaprabhaker in forum New To Java
    Replies: 5
    Last Post: 05-13-2008, 05:59 AM
  5. Replies: 1
    Last Post: 02-15-2008, 04:07 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •