• 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
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

tracking the creations of objects

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All
I want to track the number of objects created and memory used during the execution of a java program.I want to implement it as a thread which will concurrently run with the application
Can anybody help me in this regard
 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just a thought: Create a separate thread to run concurrently with the main thread. Every time the main thread creates an object that you want to track, it increments a static counter. The other thread has only to display that counter.
 
Shyam Purkayastha
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes that is my idea even.
But how will i know wheather an object has been created by the main method
Any special classes in java which can detect the creation or initialization of objects
 
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are some profiling tools that support this feature.
If you want to do it yourself, it can be done but not easily. You have to override the Object class. This will catch the construction of every object (except arrays) unless they are created with clone(). The book "Java Performance Tuning" discusses this if you can get your hands on a copy.
 
Doanh Nguyen
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Shyam Purkayastha:
Yes that is my idea even.


I guess you need a monitoring utility...
[ September 24, 2002: Message edited by: Doanh Nguyen ]
 
Shyam Purkayastha
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Doanh
can u name a few monitering utilities available for java
 
Doanh Nguyen
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Shyam Purkayastha:
a few monitering utilities available for java


I would be happy if only one exists. No I cannot name any. Maybe none exists. JVM controls execution of threads, which may run concurrently but independent of one another. If there is any monitoring exist, it must come JVM itself.
 
Ranch Hand
Posts: 269
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Doesn't the java option -Xrunhprof fit your need?
If yes and for ergonomic use, you may have a look and the HP site. Look for "HPJmeter".
W.
 
Just the other day, I was thinking ... about this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic