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

  • Home
  • SEARCH
  • 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 580835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:30:55+00:00 2026-05-13T14:30:55+00:00

How are those different Method types handled in memory. I found two different explanations

  • 0

How are those different Method types handled in memory.

I found two different explanations to this:

  1. Static methods are only once in memory, whereas instance methods are in memory multiple times, one for each instance to handle the references to membervariables correctly in each instance.

  2. All methods are only once in memory and instance methods do only get the instance of the object as parameter.

What way is used by the different compilers?

  • 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-13T14:30:55+00:00Added an answer on May 13, 2026 at 2:30 pm

    The short answer, as Johannes said, is nearly always #2. Both will only exist in memory in a single location, but instance methods have context (which is basically an extra hidden argument) that gives them access to the instance.

    But: Some languages/environments will instantiate a function that looks (to a naive reading of the source code) like one function multiple times. JavaScript is a good example of this: The function object closes over the scope in which it’s defined, so if there are multiple scopes (such as a function being called more than once), multiple distinct function objects result. (Interpreters/JIT-ers may optimize whether the code is duplicated, but conceptually it is and the function references differ.)

    Here’s an example in JavaScript:

    function foo() {
    
        alert("hi there");
    }
    
    function buildBar(x) {
    
        function bar() {
            alert(x);
        }
    
        return bar;
    }
    
    var f1, f2;
    
    f1 = foo;
    f2 = foo;
    f1();
    // alerts "hi there"
    f2();
    // alerts "hi there"
    alert("f1 === f2 ? " + (f1 === f2));
    // alerts "true", there is only one `foo`
    
    var b1, b2;
    
    b1 = buildBar("one");
    b2 = buildBar("two");
    b1();
    // alerts "one"
    b2();
    // alerts "two"
    alert("b1 === b2 ? " + (b1 === b2));
    // alerts "false", there are two `bar`s
    

    This becomes relevant in certain implementations of “private” instance data in JavaScript, where people define the instance methods within the constructor (much as buildBar defines bar) so they have access to private variables declared within the constructor. This has the desired effect (private instance data), but the impact of multiple function instances — one for each instance of the object.

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

Sidebar

Ask A Question

Stats

  • Questions 302k
  • Answers 302k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer No, I do not believe there is. May 13, 2026 at 8:20 pm
  • Editorial Team
    Editorial Team added an answer I found the problem and its solution. The idea is… May 13, 2026 at 8:20 pm
  • Editorial Team
    Editorial Team added an answer If you're using Flex 3, that someImageClass, if it's just… May 13, 2026 at 8:20 pm

Related Questions

I'm reading a lot about good and bad practices in OOP design. It's nice
PHP, as we all know is very loosely typed. The language does not require
I have an object which straight forward instance variables. Some are NSString, some are
I'd like to have your opinion on a specific case, please. This is about
i want to dispatch messages to specific handlers through a common message processor //

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.