Stack size

  • Thread starter Thread starter Dennis C. Drumm
  • Start date Start date
D

Dennis C. Drumm

Is there a way to keep track of how much memory a stack object is consuming,
considering it may contain a wide variety of objects that do not easily lend
themselves to computing a size?

Thanks,

Dennis
 
Objects that are allocated on the stack in .NET (that can only be value
types and object references - not the objects themselves) are always of a
fixed size. If a value type has a reference to a reference type then all
that is on the stack is a 32 bit reference, the rest of the memory is
allocated on the managed heap and is cleaned up by garbage collection ...

or have I misunderstood you question?

Regards

Richard Blewett - DevelopMentor
http://staff.develop.com/richardb/weblog
 
Richard,

I could be wrong but I guess OP is asking about the stack class and the size
it takes when containg a 'wide variety' of objects.
Anyway there is no managed way of knowing the CLR object size be it a stack
object or any other object.

Willy.
 
Thanks guys.

So, the next question is:, can I monitor how much stack and heap memory my
program consumes?

Dennis
 
Programmatically? I guess you could use the unmanaged profiling API?but that isn?t exactly non-invasive.

Otherwise you could use perf mon - that has performance counters for .NET

And if you want a static view of the allocation profile of your application you could try the CLR Profiler

Hmm I'm not sure if you can get stack allocation from these though

Regards

Richard Blewett - DevelopMentor
http://staff.develop.com/richardb/weblog

nntp://news.microsoft.com/microsoft.public.dotnet.languages.csharp/
Thanks guys.

So, the next question is:, can I monitor how much stack and heap memory my program consumes?

Dennis


"Richard Blewett" wrote in message news:%[email protected]...
LOL

yes now I read it in that context its obvious - thank Willy

Richard

"Willy Denoyette [MVP]" wrote in message


---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.760 / Virus Database: 509 - Release Date: 10/09/2004

[microsoft.public.dotnet.languages.csharp]
 
Thanks Richard,

I will check out the optioins you mention.

Dennis


Richard Blewett said:
Programmatically? I guess you could use the unmanaged profiling API?but
that isn?t exactly non-invasive.

Otherwise you could use perf mon - that has performance counters for .NET

And if you want a static view of the allocation profile of your
application you could try the CLR Profiler

Hmm I'm not sure if you can get stack allocation from these though

Regards

Richard Blewett - DevelopMentor
http://staff.develop.com/richardb/weblog

nntp://news.microsoft.com/microsoft.public.dotnet.languages.csharp/
Thanks guys.

So, the next question is:, can I monitor how much stack and heap memory my
program consumes?

Dennis


"Richard Blewett" wrote in message
LOL

yes now I read it in that context its obvious - thank Willy

Richard

"Willy Denoyette [MVP]" wrote in message


---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.760 / Virus Database: 509 - Release Date: 10/09/2004

[microsoft.public.dotnet.languages.csharp]
 
Back
Top