• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 236
  • Last Modified:

Query on Static function

Hi all,

Which one takes more memory a static function or a non static function and why?

thanks
0
arijit_rebaca
Asked:
arijit_rebaca
1 Solution
 
fridomCommented:
None, why should there be  a difference?

Regards
Friedrich
0
 
srinimsCommented:
both will take the same memory
non static variable might have a multiple occurance. but non static function will have only only one occurance.
0
 
PaulCaswellCommented:
arijit_rebaca,

Generally, they will use exactly the same memory. However, there are obscure situations where they might end up different.

In a library, a static function may take slightly less memory because since it cannot be accessed by the main program, it does not need to store its address anywhere else in the library.

An optimiser can take advantage of its knowledge that a particular function is static to perform extra optimisation. For example, it it could remove some parameters from the stack frame and pass and return them in registers. It could also inline the function. Unfortunately, neither of these processes would predictably decrease the size of the function, and the inlining could actually increase the effective size.

There may well be others I havent thought of.

Paul
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now