Does declaring STATIC causes memory problems ?

Posted by Akiii under C# on 3/3/2012 | Points: 10 | Views : 2499 | Status : [Member] | Replies : 7
Hi friends,

Please give your view on static classes, methods and variables. Does declaring those increases our application's memory consumption ?



Regards
Akiii




Responses

Posted by: Nishantcomp2512 on: 3/4/2012 [Member] Starter | Points: 25

Up
0
Down
program will allocate memory to static field at compiled time not a run time, so initailly memory is assigned all static members.

Akiii, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Akiii on: 3/4/2012 [Member] Bronze | Points: 25

Up
0
Down
Does that mean that if there are 500 functions/variables declared as static then it will be a resource hog ?


Thanks and Regards
Akiii

Akiii, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: CGN007 on: 3/5/2012 [Member] Silver | Points: 25

Up
0
Down
The below resources will be useful
http://stackoverflow.com/questions/337019/hows-memory-allocated-for-a-static-variable
http://www.codeproject.com/Articles/15269/Static-Keyword-Demystified

Akiii, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Akiii on: 3/6/2012 [Member] Bronze | Points: 25

Up
0
Down
Hi @CGN007,

Static-Keyword-Demystified article is a great one. Thanks for the link. but my question remains un-answered - Does declaring those increases our application's memory consumption ??


Regards
Akiii

Akiii, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hmanjarawala on: 3/6/2012 [Member] Bronze | Points: 25

Up
0
Down
Hi check this out:
http://stackoverflow.com/questions/4062138/memory-management-for-static
http://social.msdn.microsoft.com/Forums/hi-IN/netfxbcl/thread/e6bd8003-d95b-4ecf-9c16-c47be73e34bf

Himanshu Manjarawala
Sr. Software Engineer@AutomationAnywhere
http://fieredotnet.wordpress.com/

Akiii, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Akiii on: 3/6/2012 [Member] Bronze | Points: 25

Up
0
Down
Thank you @Himanshu for the above links !


Regards
Akiii

Akiii, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: CGN007 on: 6/29/2012 [Member] Silver | Points: 25

Up
0
Down
Mark as Answer if its helpful to you,that motivates...

Akiii, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response