• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

need general help debugging unexplained freezes

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys!

I need some good tricks to debug occaisionally occuring und completely unexplainable freezes in my Swing application.

I would post some code snippets but the project is really large and I have not the slightest idea where there freezes could be originated. There must be some tool or trick or something for me to do to track down the source of all this problems.

By the way: when I say 'freeze', I mean that my application freezes completely and never comes back to life. The application is single threaded, I use loops really rarely and double-checked all of then nearly 50 times until now. I tried eclipse debug mode but at the moment the application freezes, there are really no suspicious values or object in the tracing system.

This is really giving me a hard time and I hope someone has some tricks to share with me...

Ph0enix
 
lowercase baba
Posts: 13091
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
System.out.println is your best friend. You can also use things like log4j. i will often put "entering method A" and "exiting method A" statements on all my methods. run the program, wait for it to hang, then analyze your logs.

if the last thing printed was "entering method Q", take out all the other logging statement, and put a ton in method Q.
 
Paul Disto
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Fred,

but it will use up weeks or even more to put System.out.println([methodName]) in every method. It could help *perhaps* but it could also help not an inch. That's because the project makes plenty use of recursive methods where it can and I doubt that it will help me to see, which method triggered my application to death. I'm pretty sure it's no loop.

I will do as you proposed if there are no other possibilities. Aren't there any tools for this kind of situation out there? Some kind of more advanced debugger?
 
Rancher
Posts: 2759
32
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How long is the freeze? If it's long enough, you could get couple of thread dumps of the app when it freezes and see which method it is executing when it froze

You might also want to check what's happening with GC. When GC is triggered it momentarily freezes your app. Normally, this is not a issue because it;s not noticeable. However, if your app is at the point of running OOM, GC might be getting triggered continuously, and everything will slow down. It might look like a freeze even though it isn't. Again the thread dump will give you how much memory is being used at the time of the freeze

You can also use JConsole. Start your app. Start JConsole and connect to you app. Jconsole will show you a nice graph of how the memory is being used, and also will let you inspect the stack of any thread being used in the app. It doesn't give you more info than thread dumps, but because it gives a visual representation, it's nicer to use.
 
Paul Disto
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your suggestion, I will try that at next opportunity. But not now, because I have to catch a train. I will try it monday morning.

If this freeze occurs it never lets my application continue its work. In other words: it's infinite. I am sure it's some kind of memory related issue. I'll try to track it down with JConsole.
 
Jayesh A Lalwani
Rancher
Posts: 2759
32
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If it's an infinite recursion, then you should get StackOverflowException pretty soon. However, it depends on how long each recursion takes.

If it's high memory usage, it should run out of OOM eventually. However, because of the way GC works, when it you are at the point of OOM, the app slows down, which results in new objects being created slowly. So, it stays at the point of OOM for a long time. I've seen JBoss freeze overnight because of OOM.

If it;s an infinite loop, it will truly stay frozen infinitely forever. This is very likely. It's very easy to do a silly mistake like this



>
 
Paul Disto
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've tried JConsole today (absolutely no time for that yesterday). It's a great tool in my opinion and it doeas not freeze like my application when this strange kind of behavior occurs. But I was not able to track down the problem until now. I will continue to experiment with JConsole. Perhaps I might find some useful information. I can at least say that the "detect freeze" button always returns "no freeze detected" and at least sone thread still seems to be active (but without noticable result even after some hours!).

Thank you for your help guys. I will post when I solved my problem or when I need further help with it. But this could take some days or weeks in the worst case (this problem is severe but I got other work to do, too...).
 
Jayesh A Lalwani
Rancher
Posts: 2759
32
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
DO you mean "detect deadlock" button? That will only detect deadlocks, which can be one potential cause for freeze. If you have only one thread in your app, you won't have deadlocks. The detect deadlock button won't detect infinite loops. When it freezes, you will have o manually look at the stack trace of your thread
 
Paul Disto
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, I meant "detect deadlock". I thought so.

I'm only using one thread but I'm using other Objects that create their own threads (ex: Timer). There is quite a good number of these objects so there is a good number of threads to check. For that I will need some time. I'll talk back then.
 
Oh the stink of it! Smell my tiny ad!
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic