I started using Resharper and it indicated when a method could be made static. Would converting a few hundred methods to static methods increase the memory footprint over a large period of time?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No – Changing to static methods has no effect on memory.
The first time a type is referenced (whether static or non-statically), any static members are initialized and static constructors are run.
However, if you’re just considering switching methods from non-static to static, this will have no effect on garbage collection or total memory footprint.
You only have to worry about memory footprint changing if you change class members to be static members. In this case, static fields will stay rooted once the type is accessed, and will not get collected by the GC. This is typically only done when necessary, and by design – you make a member static because you want it to persist.