Bookmark Topic Watch Topic
  • New Topic

Determine Objects created

 
John Vergis
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi,
Is it possible to determine the number of objects that has already been created. For example if n objects of Class 'Test' has been created, I would like to find this value(n).

Thanks
John
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Report post to moderator
You can have a public static (class) variable that your constructor(s) increment to get total number of instances of that particular class created. Is that what you mean?
Bill
 
John Vergis
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Report post to moderator
No, I was just wondering whether I will be able to get the number of objects that are created at runtime. As u pointed out, class variable which is incremented at every new() call , is one option of finding the instances that are created, I doubt there is any API to find out that either.

I was looking for something like the Reflection API's which help us to get a whole lot of info at runtime.

Thanks
John
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24213
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Report post to moderator
John --

Please don't post the same query to multiple forums -- it just wastes people's time and spreads out what might otherwise be a single coherent discussion. Further followups can go here, as this doesn't seem to have anything to do with performance.
 
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!