Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>when are the functions put on the stack ?</p> </blockquote> <p>The stack contains data, not functions. It wouldn't make sense to pre allocate space for a function as it can be called recursively, or not at all.</p> <blockquote> <p>when they are compiled , each function is put on the stack , </p> </blockquote> <p>Where did you read this?</p> <blockquote> <p>and then when an object calls it , </p> </blockquote> <p>Threads run code, not objects.</p> <blockquote> <p>it goes to that function on the stack ?</p> </blockquote> <p>Nothing like it.</p> <blockquote> <p>first the main function is loaded onto stack , </p> </blockquote> <p>functions are not loaded on the stack.</p> <blockquote> <p>then objects are allocated in heap , </p> </blockquote> <p>probably, though they can be allocated on the stack with escape analysis.</p> <blockquote> <p>and then as the objects call the function they are put onto the stack , </p> </blockquote> <p>Threads call methods and when a method is called it can optionally allocate a stack frame. That stack frame can contain local variables and stack assigned objects.</p> <blockquote> <p>each time allocating memory to the local vars on the stack ?</p> </blockquote> <p>Each method call can allocate a single block of memory for all local variables which use memory. Note: some local variables can be assigned to registers and might not use stack.</p> <blockquote> <p>and do static methods also follow the same procedure ,</p> </blockquote> <p>There is no real difference between static and non-static methods except non-static methods will have an additional argument at the start for the instance.</p> <blockquote> <p>like the normal functions , cause i heard they are allocated memory only once.</p> </blockquote> <p>methods only allocate once per call. Say you have a loop with a local variable inside it, it will still only be allocated once.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload