Call stacks

Each coroutine and thread has its own call stack. This means that a coroutine or a thread is created along with its call stack. A call stack contains something like blocks for each function that is invoked using a context of this thread or coroutine. This block represents a memory space that contains metadata, primitive local variables, and local references to objects in the heap. You can consider a call stack a part of the memory that is allocated for a thread or coroutine.

The following diagram shows how a Call stack looks when a thread or coroutine is created:

If the main() function invokes another function, a new block is added to the call stack. This looks as follows:

When the loadImage function returns a value to the main function, the block of the loadImage function is removed from the stack.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.2.225