Click here to Skip to main content
15,889,281 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
I am working on a C# windows application. For this I have created many classes, in those classes most of the methods are static. I want to know when memory will be allocated for these static methods and when that will be cleared by GC. Is it good practice to create methods as static compared to method invoked on an instance based. When I launch my application, its consuming lot of memory, I assume that it’s because all the methods are static.
Posted
Comments
Arkadeep De 6-May-15 3:39am    
you may have take a look this one
http://stackoverflow.com/questions/6719126/memory-allocation-for-regular-class-static-class-static-method-instanve-method-a?answertab=active#tab-top
BillWoodruff 6-May-15 5:03am    
What makes you think static Methods are ever garbage collected ?

1 solution

static methods not consume more memory than instance ones (you have to look elsewere...)
You should use static methods for 'class functionalities' that is for functionalities that don't depend on a particular instance of the class.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900