Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6894435
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:46:57+00:00 2026-05-27T06:46:57+00:00

In the wake of this question about static methods in managed code , I’m

  • 0

In the wake of this question about static methods in managed code, I’m interesting if the answers there is relevant to unmanaged code like c++.

I make thousands of instances, and my question is mainly about static methods. Do this methods save memory compared regular methods?

thank you, and sorry about my poor English.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T06:46:58+00:00Added an answer on May 27, 2026 at 6:46 am

    All methods require their binary code to be in memory in order to run. The executable code for static and non-static methods is (largely) the same.

    Both types of methods require only one place in memory, so they’re not replicated with every instance of the class.

    Let’s now take a look at some code:

    class A
    {
    public:
       void foo();
       static void goo();
    };
    
    void A::foo()
    {
    004113D0  push        ebp  
    004113D1  mov         ebp,esp 
    004113D3  sub         esp,0CCh 
    004113D9  push        ebx  
    004113DA  push        esi  
    004113DB  push        edi  
    004113DC  push        ecx  
    004113DD  lea         edi,[ebp-0CCh] 
    004113E3  mov         ecx,33h 
    004113E8  mov         eax,0CCCCCCCCh 
    004113ED  rep stos    dword ptr es:[edi] 
    004113EF  pop         ecx  
    004113F0  mov         dword ptr [ebp-8],ecx 
    }
    004113F3  pop         edi  
    004113F4  pop         esi  
    004113F5  pop         ebx  
    004113F6  mov         esp,ebp 
    004113F8  pop         ebp  
    004113F9  ret     
    
    
    void A::goo()
    {
    00411530  push        ebp  
    00411531  mov         ebp,esp 
    00411533  sub         esp,0C0h 
    00411539  push        ebx  
    0041153A  push        esi  
    0041153B  push        edi  
    0041153C  lea         edi,[ebp-0C0h] 
    00411542  mov         ecx,30h 
    00411547  mov         eax,0CCCCCCCCh 
    0041154C  rep stos    dword ptr es:[edi] 
    }
    0041154E  pop         edi  
    0041154F  pop         esi  
    00411550  pop         ebx  
    00411551  mov         esp,ebp 
    00411553  pop         ebp  
    00411554  ret           
    
    
    
    int main()
    {
       A a;
       a.foo();
    0041141E  lea         ecx,[a] 
    00411421  call        foo (4111E5h) 
       a.goo();
    00411426  call        A::goo (4111EAh) 
       return 0;
    }
    

    There are only minor differences, such as pushing the this pointer onto the stack for the non-static function, but they are minor, and probably a decent optimizer will reduce the differences even further.

    A decision about whether or not to use static functions should be strictly design-driven, not memory-driven.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I think this question is very usual. Many results on Stackoverflow has said about
This question is not about, whether spurious wakeups actually happen, because this was already
Edit: I'd like to plead temporary insanity for even asking this question, but it
My Question is similar to this one How can I wake an android device
Is there an environment in LaTeX to accomplish this? Feb 22 06:00AM - Wake
I want to wake system from sleep programmatically, is there any way to do
Why does this code cause a deadlock? THREAD 1: EnterCriticalSection( &lock_ ); ... Create
This is a follow-up question to this: Rebuilding a packet to inject via pcap
This question sounds so easy I can't believe I can't find information on it
Can anyone explain what this method of PowerManager.Wakelock is for? setReferenceCounted Wake locks are

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.