IOS Stack-memory-code running on a computer

Source: Internet
Author: User

In fact, no matter what the program is, what language is the ultimate goal of dealing with machines, how do we write program computers ???

Running our program on a computer is nothing more than combining disk-memory-cpu.

We must write a program code in this disk, but we merge the code we write into a file according to certain rules (. Exe)also refers to our normal installation package. When we run the. exe file, it is our program execution,

// Note: Do not treat programs as running programs in the Code. A program can be divided into three steps: writing, compiling, and execution. Each program must go through these three steps.

Writing: the code we write

Compile: the code we write is combined into a file according to certain rules (. Exe)

Execution: During execution, the system assigns a certain amount of memory to our program. At this time, the memory is called (stack), and then the program starts to find the main () Entry of the program (), locate and start row-by-row execution (each line of code has a memory ),

Heap: in the main () function, we encounter "alloc" (many of which are new keywords in other languages), which means we have generated a heap;

// Stack is limited while stack is infinite

 

# Import <Foundation/Foundation. h>

 

@ Interface fist: NSObject

{

Int;

Int B;

}

@ Propertyint a, B;

-(Void) Print;

@ End

 

 

@ Implementation fist

@ Synthesize a, B;

-(Void) Print

{

NSLog (@ "a = % db = % d", a, B );

}

@ End

 

Int main (int argc, const char * argv []) // stack appearance

{

@ Autoreleasepool {

// Insert code here...

Fist * one; // defines the pointer of A Class (in a 32-byte system, only 4 bytes of memory are occupied)

One = [fist alloc]; // declare the memory for one (at this time we have "heap)

One = [one init]; Initialization class (in fact, init is an initialization function, so you don't need to elaborate on it here)

Int a = 0; // here we have returned to the stack.

}

Return 0;

}

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.