Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Does static methods use up the application resources, which will not be released even if the instance of that class is released?

And is there any potential risk to static methods if their class will be used in a multi-threading environment?

In design wise, when should we use private static methods and when should not?
Posted

1 solution

Let me try to make you clear about that.

with static method It would have one and only instance you will access same instance when you call the static method, So it solves the problem of memory consumption.

While with instance method method inside every object will have different values and that will be different for each object.

Though memory resources is less in static method but If you want different value for instance method then go for it only.

Hope this helps.

Please vote and Accept Answer if it Helped.
 
Share this answer
 
Comments
Rajesh Anuhya 1-Dec-10 1:53am    
Good 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