.NET Questions (CLOSED)

Questions and Answers on any aspect of .NET. Now closed.

This discussion group is now closed.

Have a question about .NET development? Try stackoverflow.com, a worldwide community of great developers asking and answering questions 24 hours a day.

The archives of .NET Questions contain years of Q&A. Even older .NET Questions are still online, too.

Number of objects in memory

Hello,
I'm looking for a way to count the number of objects currently in the managed heap. I want something like:
- Class1 10 objects
- Class2 20 objects
- etc.
Is there any "simple" way to do this?
If not any good profiler that can do something like this?

Thanx,
Albert
Albert Send private email
Wednesday, January 24, 2007
 
 
The "CLR Profiler" is a free tool provided by Microsoft that will tell you more than you'd ever want to know about things like this.  I have limited experience with it though.  It seemed interesting about a year ago, when I was about to start a large .NET application, but then it turned out that we just plain didn't need to know what was going on in such detail.  Whenever we had a performance problem, the solution had nothing to do with how much we were keeping on the heap.
Notorius L
Wednesday, January 24, 2007
 
 
Thanx for your reply.
I have checked CLR Profiler but it has too much information and I can't find a way to get the count of objects.
I don't have many problems with the performance, but there's a memory leak and the memory grows over time...

Albert
Albert Send private email
Wednesday, January 24, 2007
 
 
Most memory leaks in .NET are caused by not releasing unmanaged objects. If you are instantiating fonts, brushes, pens, or anything else that uses unmanaged GDI resources then you need to call dispose on them. Other than that I don't know what else to tell you.
dood mcdoogle
Wednesday, January 24, 2007
 
 
The other common cause of memory leaks in .NET is a static collection (often some kind of caching or object pooling that you're doing) that has items added that never get dropped.
Mike S Send private email
Wednesday, January 24, 2007
 
 
>> The other common cause of memory leaks in .NET is a static collection (often some kind of caching or object pooling that you're doing) that has items added that never get dropped.

I think that may be the reason but I need to now the number of objects in memory. It seems ".NET memory profiler" may do the job....
Albert Send private email
Wednesday, January 24, 2007
 
 
el
Thursday, January 25, 2007
 
 
you can query the state of the heap using the Immediate window while in debug mode inside your code. you can also get a total mem count (System.GC.Something) before and after an allocation and get a _ballpark_ value on the mem size.
There's a whole article on that kind of debug spelunking in Code Magazine online somewhere (by that blondie chick who knows her shit!)
jonathan Send private email
Thursday, January 25, 2007
 
 

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
 
Powered by FogBugz