• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Determining program memory and speed

 
justin smythhe
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 49367
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1557
5
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As Campbell has suggested, in built tools are much easy to use and quite reliable. One utility is jvisualvm.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49367
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anayonkar Shivalkar wrote:. . . One utility is jvisualvm.
That is probably what I meant. Sorry for getting the name wrong.
 
Anayonkar Shivalkar
Bartender
Posts: 1557
5
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For more detail about java visual VM => visualvm tutorial
 
Winston Gutkowski
Bartender
Pie
Posts: 10422
63
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic