• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Application locking up

 
Ranch Hand
Posts: 229
  • Number of slices to send:
    Optional 'thank-you' note:
Hi everyone,

I have a problem with my application. Everytime I run it after a minute or so it locks up. I'm not sure what is causing thins - if its too many threads, or what? Could you please give me some suggestions
on how to resolve this,


Thanks,

Ted
 
Ranch Hand
Posts: 91
  • Number of slices to send:
    Optional 'thank-you' note:
Hi Ted,

What kind of application are you running ? What does it do ? Can you post the code ?
 
Bartender
Posts: 1868
81
  • Number of slices to send:
    Optional 'thank-you' note:
As Mano pointed out there are too many unknowns are this point especially without any code.

However here are a few stabs in the dark:
  • Many times people have issues with concurrency/mult threaded programming
  • This could be related to only your system e.g. AntiVirus software or firewall
  • Inaccessible or slow resource(s)

  • As you can see, without any code to analyze the problems can range drastically.
     
    Ted Gress
    Ranch Hand
    Posts: 229
    • Number of slices to send:
      Optional 'thank-you' note:
    It is a 3D game editor...well its supposed to be. I use a lot of static classes and threads and I think that's part of it but I'm not convinced that's the only problem lurking.


    The main function that initializes all the threads etc... is below:





     
    Marshal
    Posts: 79424
    377
    • Number of slices to send:
      Optional 'thank-you' note:
    How many Threads have you got? Why?
    That code is difficult to read because so much of it is commented out. Please remove the commented out code and the unnecessary whilespace.
     
    Ranch Hand
    Posts: 52
    1
    • 1
    • Number of slices to send:
      Optional 'thank-you' note:
    You can capture JFR of the application, it will shed more light in to which part of code is causing the contention, what are the threaddumps, is there any issues with memory/cpu utilisation etc.
     
    Ted Gress
    Ranch Hand
    Posts: 229
    • Number of slices to send:
      Optional 'thank-you' note:
    Here, comment free

     
    Rancher
    Posts: 5008
    38
    • Number of slices to send:
      Optional 'thank-you' note:
    Can you add print statements to track where the code is executing?  The print out should show where the execution flow is going and what the values of key variables are as they are used.
    For example if there is a tight loop that is running forever, the print outs inside the loop will go forever.
     
    Ted Gress
    Ranch Hand
    Posts: 229
    • Number of slices to send:
      Optional 'thank-you' note:
    As I thought, this code seems to be the bottleneck. Is there a way I can optimize it?


    MainMerged.java (entry poitn)


    CClock.java



    and Timer Manager


    I'm also getting this exception in Loop.java:



    Loop.java:

     
    Ted Gress
    Ranch Hand
    Posts: 229
    • Number of slices to send:
      Optional 'thank-you' note:
    Is there a way I can write a new line into the output when using printwriter. Can I do a simple
    \n?
     
    Norm Radder
    Rancher
    Posts: 5008
    38
    • Number of slices to send:
      Optional 'thank-you' note:

    As I thought, this code seems to be the bottleneck


    How have you determined that?

    write a new line into the output when using printwriter.


    See the API doc for the PrintWriter class.  It has several methods that will write a new line.
     
    Ted Gress
    Ranch Hand
    Posts: 229
    • Number of slices to send:
      Optional 'thank-you' note:
    Ok. I'll look up append. Nothing showed up on the intellisense so I assumed (my fault) that there wasn't one.


    As far as the bottleneck goes, when I uncommented that code the game engine worked fine. Well it didn't hang up anyway. As sooon as I uncommented it, it started locking up again. I'm not sure how to fix the problem however.
     
    Ted Gress
    Ranch Hand
    Posts: 229
    • Number of slices to send:
      Optional 'thank-you' note:
    As for PrintWriter, I just looked it up in the API and the writer function doesn't have any newline . I'm looking for something like println. Does that exist on the file side?
     
    Norm Radder
    Rancher
    Posts: 5008
    38
    • Number of slices to send:
      Optional 'thank-you' note:
    What API doc did you look in?  Here are a few lines for the PrintWriter class:


    void println()
    Terminates the current line by writing the line separator string.
    void println(boolean x)
    Prints a boolean value and then terminates the line.
    void println(char x)
    Prints a character and then terminates the line.
    void println(char[] x)
    Prints an array of characters and then terminates the line.
    void println(double x)
    Prints a double-precision floating-point number and then terminates the line.
    void println(float x)
    Prints a floating-point number and then terminates the line.
    void println(int x)
    Prints an integer and then terminates the line.



    when I uncommented that code


    What lines in what class are you talking about?
     
    Ted Gress
    Ranch Hand
    Posts: 229
    • Number of slices to send:
      Optional 'thank-you' note:
    For the above mentioned Main class:

    public class MainMerged {

    // The role of this class is to test out all the
    // programmatic systems before graphics are
    // introduced

    public static MessageManager messageManager = new MessageManager();
    public static SceneGraphManager sceneGraph = new SceneGraphManager();
    public static WebServiceFactory webServiceFactory = new WebServiceFactory();
    public static GameBlackboard gameBlackBoard = new GameBlackboard();
    public static XMLAdapter xmlAdapter = new XMLAdapter();
    public static ObjectManager objManager = new ObjectManager();
    public static ThreadFactory threadFactory;
    public static CEventManager eventManager = new CEventManager();
    public static PublishingManager publishManager = new PublishingManager();
    public static CScheduler scheduler = new CScheduler();
    public static CTaskManager taskManager = new CTaskManager();
    //public static Profiler profiler = new Profiler();
    public static DTIClass dtiClass = new DTIClass("Main", null);

    public static OutputLog log = new OutputLog();

    // UI classes
    public static Inspector ins = new Inspector();
    public static InspectorManager insm = new InspectorManager();
    public static Manager manager = new Manager();
    public static UserInterface ui = new UserInterface();
    public static GameLogic gameLogic = new GameLogic();
    static boolean simulate = false; // set to true to run simulation without rasterization
    static RunThrough runThrough = new RunThrough();
    public static InputHandler inputHandler = new InputHandler();
    public static InputManager inputManager = new InputManager();

    //

    // clock object
    public static CClock clock = new CClock();

    public static CProfiler profiler = new CProfiler();

    public static JournalManager journal = new JournalManager();

    public static Shell shell = new Shell();


    public static void main(String[] args) throws InterruptedException, FileNotFoundException {
    System.out.println("Welcome to NecroTek3D");

    // initialize journaling system
    JournalManager journaling = new JournalManager();
    Thread journalingThread = new Thread(journaling);
    journalingThread.start();

    CJournal.Journal(MainMerged.class, "Testing CJournal");

    JournalManager.beginJournal();

    ////Thread t0 = new Thread(log);
    ////t0.start();


    // Launch Profiler, Journal, and Logging Systems
    Thread m = new Thread(profiler);
    m.start();
    CProfiler.ProfileBegin("Main Merged");

    // Launching Journal
    CJournal.Journal(Main.class, "Launching the Journaling ");

    Thread j = new  Thread(journal);
    j.start();

    //initializing clock system
    ////JournalManager.JournalEntry(MainMerged.class, "main", "Launching clock timer thread");
    ////Thread c = new Thread(clock);
    ////c.start();

    // Initialize scheduling system
    ////CJournal.Journal(Main.class, "Launching the scheduling system");
    ////CTimerManager.init();
    ///CJournal.Journal(Main.class, "Begin Timing. Testing Timer Unit");

    // Initialize a dummy timer
    ////CTimer dummy_timer = CTimerManager.getNewTimer(30, 2);

    // Create a test message

    Message message = new Message();
    message.mflag = EEventMachine.TEST_EVENT_1;

    CJournal.Journal(Main.class, "Testing messaging system " + message.mflag.toString());
    CJournal.Journal(Main.class, "Set message.mflag to " + message.mflag.toString());

    CJournal.Journal(Main.class, "Testing Task Manager");

    CTask task = new CTask();
    task.message = message;

    CJournal.Journal(Main.class, "Set task message to dummy message");

    CJournal.Journal(Main.class, "Testing Scheduler");

    CScheduler.addToSchedule(task);

    CEvent event = new CEvent();

    CJournal.Journal(Main.class, "Testing Event Manager");
    CJournal.Journal(Main.class, "Created dummy CEvent. Pushing to event manager.");

    CEventManager.push_events(event);

    // Initialize memory system

    /*
    * CJournal.Journal(Main.class, "Testing Memory System");
    *
    * CJournal.Journal(Main.class, "Establishing memory pool");
    *
    * objManager.InitPool();
    *
    * CJournal.Journal(Main.class, "Attempting memory request: Dummy string object"
    * );
    *
    * String stringObject = (String) ObjectManager.requestObjectOfClass(String);
    *
    * //System.out.println(stringObject);
    *
    * CJournal.Journal(Main.class,
    * "Attempting integer memory request. Dummy integer objects");
    *
    * Integer intObject = (Integer) ObjectManager.requestObjectOfClass();
    *
    * //test formula
    *
    * int a = 0; int b = 1; int c = intObject.intValue(); c = a + b;
    *
    * CJournal.Journal(Main.class, "Dumy keycode for memory. Value is " + c +
    * "should add to 1");
    *
    */

    // Initialize Thread Pooling Thread System?
    ////threadFactory = Executors.defaultThreadFactory();

    // initialize message manager
    CJournal.Journal(Main.class, "Initializing message manager");
    MessageManager messageManager = new MessageManager();

    messageManager.start();

    // send bootstrap message
    CJournal.Journal(Main.class, "Testing messanger: sending bootstrapping message to messagemanager");
    Message boot_strap_message = new Message();
    boot_strap_message.mflag = EEventMachine.EM_BOOTSTRAP;
    messageManager.EnqueueMessage(boot_strap_message);

    // initializing Scene Graph (need to perform a test, declared above)
    /*
    * CJournal.Journal(Main.class, "Testing Scene Graph"); SceneGraphNode sgn = new
    * SceneGraphNode(); SceneGraphManager.add(sgn, SceneGraphManager.root);
    */
    sceneGraph.start();

    // initialziing inspector (have to rewrite)

    // initializing inspector manager (have to rewrite)

    // initializing user interface (have to rewrite)

    // initializizng web service factory

    CJournal.Journal(Main.class, "Initialzing web service factory...");

    webServiceFactory.start();

    // initializing black board

    CJournal.Journal(Main.class, "Initialzing game black board...");

    gameBlackBoard.start();

    // launching xml reader
    xmlAdapter.adapt("demo.xml");

    // launch xml reader demo

    GameInitializeService.initializeService();

    // !!!upon launching file, use hotloader to load the resources - use
    // XMLSceneLoader to get objects and add to scenegraph
    // load xml hexagon, start spawning position
    // load fringe using hotloader

    // initializing hot loader

    //CJournal.Journal(Main.class, "Initialzing hot loader...");

    /*********Initialize Hot Loader todo***********/
    //CHotLoader.InitHotLoader();

    //GameMapManager.LoadIndices();

    // initailizing input handler (have to rewrite)

    // Dumping Scene Graph Info
    ////CJournal.Journal(Main.class, "Dumping scene graph output (loaded from XMLAdapter)");
    ////SceneGraphManager.output();

    /// starting event manager
    Thread t1 = new Thread(eventManager);
    t1.start();

    // starting scheduler
    Thread t2 = new Thread(scheduler);
    t2.start();

    /// running publish manager
    publishManager.start();

    /// initializing task manager
    taskManager.start();

    // Launch profiler
    // Profiler.ProfileInit();


    CProfiler.ProfileEnd("Main Merged");

    JournalManager.JournalEntry(MainMerged.class, "main", "Preparing Game Loop");

    JournalManager.endJournal();
    JournalManager.JournalToFile();



    // 2. Game Logic Init
    //gameLogic.run();



    // testing main game loop
    ////CJournal.Journal(Main.class, "Testing main game loop");
    ////Loop loop = new Loop(); // hand over to game loop
    ////loop.start();

    ////JournalManager.JournalEntry(MainMerged.class, "main", "Preparing user interface");

    //shell thread


    // runThrough.run();

    // test bloom filter

    TestBloomFilter.testBloomFilter(5, 7, 8);


    //The method below works - don't touch it
    //ui.begin();
    ////MainMerged mainMerged = new MainMerged();
    ////mainMerged.backuprun();

    //CubeObject cube = new CubeObject();
    //CubeObject2 cube2= new CubeObject2();
    //Renderer renderer = new Renderer(true, true);
    //renderer.pushData(cube, cube2);
    ////renderer.copyIntoBuffers(cube);
    //renderer.main(null);


    ////Thread s = new Thread(shell);
    ////s.start();




    return;
    }
     
    Ted Gress
    Ranch Hand
    Posts: 229
    • Number of slices to send:
      Optional 'thank-you' note:
    Sorry, I forgot the  code block
     
    Ted Gress
    Ranch Hand
    Posts: 229
    • Number of slices to send:
      Optional 'thank-you' note:
    I commented out lines 73 through 84 which seemed to be the bottleneck. There may be others.
     
    Ted Gress
    Ranch Hand
    Posts: 229
    • Number of slices to send:
      Optional 'thank-you' note:
    I commented out lines 73 through 84 which seemed to be the bottleneck. There may be others.
     
    Ted Gress
    Ranch Hand
    Posts: 229
    • Number of slices to send:
      Optional 'thank-you' note:
    There is a bottleneck on line 221 too where TaskManager thread is started.
     
    Ted Gress
    Ranch Hand
    Posts: 229
    • Number of slices to send:
      Optional 'thank-you' note:
    There is a bottleneck on line 221 too where TaskManager thread is started.
    The main slowdown seems to actually be in my game loop:


     
    Ted Gress
    Ranch Hand
    Posts: 229
    • Number of slices to send:
      Optional 'thank-you' note:
    *bump*

    Anybody know anything about using JFR for testing?
     
    Sheriff
    Posts: 17652
    300
    • Number of slices to send:
      Optional 'thank-you' note:
    Are you referring to Java Flight Recorder? https://docs.oracle.com/javacomponents/jmc-5-4/jfr-runtime-guide/about.htm#JFRUH170
     
    Junilu Lacar
    Sheriff
    Posts: 17652
    300
    • Number of slices to send:
      Optional 'thank-you' note:

    Ted Gress wrote:I use a lot of static classes and threads and I think that's part of it but I'm not convinced that's the only problem lurking.


    The biggest, most obvious problem with that code is that it's a Big Ball of Mud.  There are almost always other problems lurking in BBoMs.
     
    reply
      Bookmark Topic Watch Topic
    • New Topic
    vceplus-200-125    | boson-200-125    | training-cissp    | actualtests-cissp    | techexams-cissp    | gratisexams-300-075    | pearsonitcertification-210-260    | examsboost-210-260    | examsforall-210-260    | dumps4free-210-260    | reddit-210-260    | cisexams-352-001    | itexamfox-352-001    | passguaranteed-352-001    | passeasily-352-001    | freeccnastudyguide-200-120    | gocertify-200-120    | passcerty-200-120    | certifyguide-70-980    | dumpscollection-70-980    | examcollection-70-534    | cbtnuggets-210-065    | examfiles-400-051    | passitdump-400-051    | pearsonitcertification-70-462    | anderseide-70-347    | thomas-70-533    | research-1V0-605    | topix-102-400    | certdepot-EX200    | pearsonit-640-916    | itproguru-70-533    | reddit-100-105    | channel9-70-346    | anderseide-70-346    | theiia-IIA-CIA-PART3    | certificationHP-hp0-s41    | pearsonitcertification-640-916    | anderMicrosoft-70-534    | cathMicrosoft-70-462    | examcollection-cca-500    | techexams-gcih    | mslearn-70-346    | measureup-70-486    | pass4sure-hp0-s41    | iiba-640-916    | itsecurity-sscp    | cbtnuggets-300-320    | blogged-70-486    | pass4sure-IIA-CIA-PART1    | cbtnuggets-100-101    | developerhandbook-70-486    | lpicisco-101    | mylearn-1V0-605    | tomsitpro-cism    | gnosis-101    | channel9Mic-70-534    | ipass-IIA-CIA-PART1    | forcerts-70-417    | tests-sy0-401    | ipasstheciaexam-IIA-CIA-PART3    | mostcisco-300-135    | buildazure-70-533    | cloudera-cca-500    | pdf4cert-2v0-621    | f5cisco-101    | gocertify-1z0-062    | quora-640-916    | micrcosoft-70-480    | brain2pass-70-417    | examcompass-sy0-401    | global-EX200    | iassc-ICGB    | vceplus-300-115    | quizlet-810-403    | cbtnuggets-70-697    | educationOracle-1Z0-434    | channel9-70-534    | officialcerts-400-051    | examsboost-IIA-CIA-PART1    | networktut-300-135    | teststarter-300-206    | pluralsight-70-486    | coding-70-486    | freeccna-100-101    | digitaltut-300-101    | iiba-CBAP    | virtuallymikebrown-640-916    | isaca-cism    | whizlabs-pmp    | techexams-70-980    | ciscopress-300-115    | techtarget-cism    | pearsonitcertification-300-070    | testking-2v0-621    | isacaNew-cism    | simplilearn-pmi-rmp    | simplilearn-pmp    | educationOracle-1z0-809    | education-1z0-809    | teachertube-1Z0-434    | villanovau-CBAP    | quora-300-206    | certifyguide-300-208    | cbtnuggets-100-105    | flydumps-70-417    | gratisexams-1V0-605    | ituonline-1z0-062    | techexams-cas-002    | simplilearn-70-534    | pluralsight-70-697    | theiia-IIA-CIA-PART1    | itexamtips-400-051    | pearsonitcertification-EX200    | pluralsight-70-480    | learn-hp0-s42    | giac-gpen    | mindhub-102-400    | coursesmsu-CBAP    | examsforall-2v0-621    | developerhandbook-70-487    | root-EX200    | coderanch-1z0-809    | getfreedumps-1z0-062    | comptia-cas-002    | quora-1z0-809    | boson-300-135    | killtest-2v0-621    | learncia-IIA-CIA-PART3    | computer-gcih    | universitycloudera-cca-500    | itexamrun-70-410    | certificationHPv2-hp0-s41    | certskills-100-105    | skipitnow-70-417    | gocertify-sy0-401    | prep4sure-70-417    | simplilearn-cisa    |
    http://www.pmsas.pr.gov.br/wp-content/    | http://www.pmsas.pr.gov.br/wp-content/    |