| Author |
Determining program memory and speed
|
justin smythhe
Ranch Hand
Joined: Jul 06, 2012
Posts: 107
|
|
How can I determine the exact (well almost) memory used by a program at a particular instant ? How can I also estimate its speed ?
Are there any case studies or examples which show how trade-offs have been made between memory and speed ?
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32644
|
|
|
That sort of thing is your lowest priority. There are all sorts of profiling tools available, including one called virtualVM or similar which comes ready‑made with Java6+.
|
 |
Anayonkar Shivalkar
Bartender
Joined: Dec 08, 2010
Posts: 1295
|
|
|
As Campbell has suggested, in built tools are much easy to use and quite reliable. One utility is jvisualvm.
|
Regards,
Anayonkar Shivalkar (SCJP, SCWCD, OCMJD)
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32644
|
|
Anayonkar Shivalkar wrote:. . . One utility is jvisualvm.
That is probably what I meant. Sorry for getting the name wrong.
|
 |
Anayonkar Shivalkar
Bartender
Joined: Dec 08, 2010
Posts: 1295
|
|
Campbell Ritchie wrote:
Anayonkar Shivalkar wrote:. . . One utility is jvisualvm.
That is probably what I meant. Sorry for getting the name wrong.
Yes, we are talking about same utility - jvisualvm comes in-built with JDK(6+).
|
 |
Seetharaman Venkatasamy
Ranch Hand
Joined: Jan 28, 2008
Posts: 5575
|
|
|
For more detail about java visual VM => visualvm tutorial
|
 |
Winston Gutkowski
Bartender
Joined: Mar 17, 2011
Posts: 4739
|
|
justin smythhe wrote:How can I also estimate its speed ?
If you mean the execution time of a specific method or program - very carefully. It's easy to make false assumptions about speed unless your testing harness is very comprehensive. At the very least you need to test multiple iterations over time and under stress and look at averages, rather than relying on single executions; but that's only scratching the surface.
Are there any case studies or examples which show how trade-offs have been made between memory and speed ?
Possibly, but you'd have to find one targeted for your specific application; and like Campbell, I'd say that this should be a very low priority. You're likely to save far more time by doing basic things like avoiding file I/O than you will by micro-optimizing. And how much is a Gb of memory these days: $50? That's about 2 hours of a junior programmer's time.
Winston
|
Isn't it funny how there's always time and money enough to do it WRONG?
|
 |
 |
|
|
subject: Determining program memory and speed
|
|
|