2

SO question is that when and where memory gets allocated for static member variable in non-static class?is this variable also in heap and its dallocations also taken care by garbage collector?

1
  • How is it relevant if the class is static or not? Commented Mar 24, 2012 at 17:14

1 Answer 1

3

The storage location is an implementation detail, but usually it should be on the Heap. Static variables are considered GC roots, so they are deallocated by the garbage collector once the AppDomain (so in most cases your application) is closed.

If you want to learn more about Garbage Collection, have a look at this article:

http://www.simple-talk.com/dotnet/.net-framework/understanding-garbage-collection-in-.net/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.