PHP object type allocation in memory, php object type allocation _ PHP Tutorial-php Tutorial

Source: Internet
Author: User
The PHP object type is allocated in the memory, and the php object type is allocated. The PHP object type is allocated in the memory. The php object type is the same as the integer, string, and other types. it is also a data type in PHP. All are used in the program to store the allocation of different PHP object types in the memory, and the php object type allocation

Object types are the same as integer and string types, and are also a data type in PHP. It is used to store different types of data in a program. when running a program, each part of its content must be loaded to the memory before being used. How is the data of the object type allocated in the memory? First, let's take a look at the memory structure. Logically, the memory is divided into four sections, namely the stack space segment, heap space segment, initial data segment, and code segment. the declarations of different types of data in the program will be stored in different memory segments. Each segment of memory has the following features.
①. Stack space segment
Stack features a small space but fast access by the CPU. it is a variable temporarily created by the user to store the program. Due to the features of the stack, the stack is particularly convenient for saving and restoring the call site. In this sense, we can regard the stack as a memory zone for temporary data storage and exchange. Memory segments used to store data types that occupy the same length of space and have a small amount of space. for example, integer 1, 100, and 10000 occupy the same length of space in the memory, the occupied space is 32-bit 4 bytes. Also, double and boolean values can be stored in the stack space segment.
②. Heap space section
Heap is used to store the memory segments dynamically allocated during the process running. it is not fixed in size and can be dynamically expanded or reduced. It is used to store data with variable data length or large memory usage. For example, strings, arrays, and objects are stored in this memory.
③. Data Segment
The data segment is used to store the initialization global variables in the executable file. In other words, it is used to store the variables statically allocated by the program.
④. Code segment
A code segment is an operation command used to store executable files, that is, it is an image of the executable program in the memory. The code segment must be prevented from being modified illegally at runtime. Therefore, only read operations are allowed, but write (Modify) operations are not allowed. For example, the functions in the program are stored in the memory.
Object Data is a data type that occupies a large amount of space and is a data type that occupies an indefinite amount of space. Therefore, after the object is created, it is stored in the memory, however, object references are stored in the stack. During running, the data in the memory occupied by the program can be directly accessed, while the heap memory cannot be directly accessed, but members in the object can be accessed through the reference name of the object.

> Fixed link: http://php.ncong.com/php_course/oop/duixiangfenpei.html

> For reprinted information, please note: ncong php was published in ncong PHP learning tutorial on September 10, July 23, 2014.


How to allocate memory for php-PHP advanced discussion

Php uses explicit memory allocation. there is no implicit memory allocation method. when defining a variable in php, we should open up a space in the memory. without c, you can use malloc alloc realloc to allocate memory.
 

In java, where is the memory space allocated when the object type is used as a real parameter?

You don't know how to learn java,

The heap memory is allocated only after the new memory is saved,

If only one object is declared, no heap memory is allocated to it.

The heap stores instantiated objects;

The struct object type is the same as the integer type and string type. it is also a data type in PHP. They are all used in the program to store different...

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.