Connecting Tech Pros Worldwide Help | Site Map

List of all Instatiated Objects

Don Stewart
Guest
 
Posts: n/a
#1: Nov 16 '05
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
don@encite.us


NuTcAsE
Guest
 
Posts: n/a
#2: Nov 16 '05

re: List of all Instatiated Objects


I might be shooting in the dark here but i think you can get that
information using performance counters...

NuTcAsE

Kevin Yu [MSFT]
Guest
 
Posts: n/a
#3: Nov 16 '05

re: List of all Instatiated Objects


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."

Evan Mathias
Guest
 
Posts: n/a
#4: Nov 16 '05

re: List of all Instatiated Objects


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.


"Don Stewart" <don@encite.us> wrote in message
news:110kncahh2ag439@corp.supernews.com...[color=blue]
> 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
> don@encite.us
>[/color]


Don Stewart
Guest
 
Posts: n/a
#5: Nov 16 '05

re: List of all Instatiated Objects


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


"Kevin Yu [MSFT]" <v-kevy@online.microsoft.com> wrote in message
news:lcKtYDxDFHA.3528@TK2MSFTNGXA01.phx.gbl...[color=blue]
> 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."
>[/color]


Don Stewart
Guest
 
Posts: n/a
#6: Nov 16 '05

re: List of all Instatiated Objects


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

"Evan Mathias" <evanmathias@hotmail.com> wrote in message
news:%23bVkLM3DFHA.3368@TK2MSFTNGP10.phx.gbl...[color=blue]
> 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.
>
>
> "Don Stewart" <don@encite.us> wrote in message
> news:110kncahh2ag439@corp.supernews.com...[color=green]
>> 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
>> don@encite.us
>>[/color]
>
>[/color]


Kevin Yu [MSFT]
Guest
 
Posts: n/a
#7: Nov 16 '05

re: List of all Instatiated Objects


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."

Closed Thread


Similar C# / C Sharp bytes