List of all Instatiated Objects

  • Thread starter Thread starter Don Stewart
  • Start date Start date
D

Don Stewart

From within a .NET 1.1 application and using C# Code,
I need to get a list of all the instatiated objects in the application,
with the following columns:

TypeName, Instatiation-Count, Size

I was thinking of using the Garbage Collector somehow or perhaps a Heap and
Stack Dump?
Using an external utility application is NOT an option.
Does anyone have any ideas?

Thank you for any assistance.
Don Stewart
(e-mail address removed)
 
I might be shooting in the dark here but i think you can get that
information using performance counters...

NuTcAsE
 
Thanks for NuTcAsE's quick response!

Hi Don,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you would like to get all instantiated
objects in the application. If there is any misunderstanding, please feel
free to let me know.

As far as I know, the current .NET framework didn't expose this kind of
method to us, which means we cannot get that in our applications. I think
the only way for us to achieve that is to use performance counters as
NuTcAsE mentioned.

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Odd question. The garbage collector is a pretty complex system, and while
there are ways to force it to delete objects, there is no way to guarantee
an object has been deleted. In essence tracking instantiated objects will
involve tracking the garbage collector, which just can't be useful, unless
you are trying to understand how it works. You may need to review what it is
you are trying to do.
 
Our software has many hundreds of classes and forms
throughout the entire solution. Due to recent Out-of-Memory
and GDI+ Drawing errors and with some manual searching,
I have discovered that there are several classes that were
NOT being Disposed.

We have a fantastic Error-Reporting mechanism
that sends loads of useful information. I want to add a list of
Types that have more than X number of instantiations to these
reports.

There are several reasons that prevent counting each class as
it gets instantiated. Also I really need to see what is actually
going on, even at the System level like Strings.

I have started to look at the Performance Counters to see
if I could find what I'm looking for. I also have found a couple
of API Functions that Get the heap, but this seems somewhat
complicated and warns that it could slow the performance of the
program until it is closed. I may end up using this method
anyways, because it is already throwing errors, and I might as
well get useful debugging info.


PS:
As a side note, I am kinda upset with how the CLR and GC
Dies when it reaches a certain level instead of consuming more
memory. This was obvious during a situation recently where:
on a Server with Dual XEON 3GHz with 4GB of Ram
and "ONLY 1 USER" Logged in! Our application crashed
from Out-Of-Memory errors while using only 301MB of
System Memory. Basically our App only shows Windows
Forms and Controls with not very much behind the scenes
data in Memory. The only applications is installed on the
System was Windows 2000 Server, Citrix and our application.

Thanks for your help.
Don
 
Our software has many hundreds of classes and forms
throughout the entire solution. Due to recent Out-of-Memory
and GDI+ Drawing errors and with some manual searching,
I have discovered that there are several classes that were
NOT being Disposed.

We have a fantastic Error-Reporting mechanism
that sends loads of useful information. I want to add a list of
Types that have more than X number of instantiations to these
reports.

There are several reasons that prevent counting each class as
it gets instantiated. Also I really need to see what is actually
going on, even at the System level like Strings.

I have started to look at the Performance Counters to see
if I could find what I'm looking for. I also have found a couple
of API Functions that Get the heap, but this seems somewhat
complicated and warns that it could slow the performance of the
program until it is closed. I may end up using this method
anyways, because it is already throwing errors, and I might as
well get useful debugging info.


PS:
As a side note, I am kinda upset with how the CLR and GC
Dies when it reaches a certain level instead of consuming more
memory. This was obvious during a situation recently where:
on a Server with Dual XEON 3GHz with 4GB of Ram
and "ONLY 1 USER" Logged in! Our application crashed
from Out-Of-Memory errors while using only 301MB of
System Memory. Basically our App only shows Windows
Forms and Controls with not very much behind the scenes
data in Memory. The only applications is installed on the
System was Windows 2000 Server, Citrix and our application.

Thanks for your help.
Don
 
Hi Don,

It was nice to hear that you have had another approach to this issue. I
think it is feasible. Thanks for sharing your experience with all the
people here. If you have any questions, please feel free to post them in
the community.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Back
Top