Which tools can I use to know the life-time or run-time of a program(from the beginning until the program ends)? I also want to know how much memory that program consumes from start to end. The program is written in Java and I'm running it on Windows XP.
-
Is this for monitoring or profiling, or to be used within the application? You can put in the start the current time, and in the shutdown get the difference and print it out. For memory it will be different, depending on how you want to get it. – James Black Oct 15 '09 at 16:47
7 Answers
You could use JConsole, here's an article describing it's usage

- 21,988
- 13
- 81
- 109

- 196,001
- 113
- 385
- 569
"How much time" a program takes is a tricky question, and the answer varies tremendously depending on the state of OS disk caches, and whether you include the start-up time of the JVM itself, etc.
The other part of your question is much easier to answer: you need a profiler. A profiler will not only tell you gross memory statistics (or gross runtime), but will allow you to pinpoint the trouble spots in your programs, areas that create an inordinate number of objects per unit time, or places that burn a lot of CPU relative to other places in your code.

- 44,698
- 7
- 80
- 103
-
Ok, thank you very much everyone. I now know where and/or how to begin my search. – Mike Oct 15 '09 at 16:58
If you're interested in monitoring, you may use jconsole
which is part of the JDK. Otherwise, please elaborate on your question.

- 35,575
- 15
- 95
- 119
You can try monitoring your application with the jconsole tool that ships with the JDK now. If that isn't enough, I'd try profiling your application with something like YourKit. Its a commercial product but extremely useful.
I understand that NetBeans has a profiler built in but I have not used it. If you're using NetBeans, that might be an option as well.

- 30,111
- 9
- 76
- 83
I use VisualVM from Sun, and its very good, with lots of useful features. You can monitor Heap Space usage, Loaded Classes, GC Activity and Live Threads.
You can also do the same for remote Java applications.

- 7,805
- 13
- 69
- 105