Oracle Memory Architecture (III)----Process memory details

Source: Internet
Author: User
Tags array contains data structures garbage collection sessions variable dedicated server oracle database
Oracle
The Process Memory:

In addition to the SGA (System Global area), the Oracle process also uses the following three global zones:

The Process Global area (PGA)

The User Global area (UGA)

The call Global area (CGA)

A lot of people don't know the difference between PGA and UGA, in fact, the difference between the two is similar to the difference between a process and a session. Although it is generally a one-to-one relationship between process and conversation, it is actually more complex than this. One obvious case is the MTS configuration, Sessions tend to be much more than processes. In this configuration, each process will have a PGA, and each session will have a UGA.PGA containing information that has nothing to do with the session, and UGA contains information that is based on a specific session.



The PGA:

The Process global Area (PGA) can be understood as either a process or a program global region. Its memory segments are in the process private area (processes private Memory) rather than in the shared Memory). It is a global zone that means that it contains global variables and data structures that all code may enter, but it is not shared by all processes. Each Oracle server process contains its own PGA, which contains only relevant information about the process. The structure in the PGA does not need to be protected by latches, as other processes are inaccessible to this area.

The PGA contains information about the operating system resources that the process is using, as well as status information about the process. Other processes use Oracle's shared resources in the SGA. The PGA is private rather than shared, and this mechanism is necessary because when the process dies, it can be purged and released.

PGA consists of two main areas: the Fixed PGA and the variable PGA or PGA Heap. The role of the fixed PGA is similar to that of the fixed SGA, which contains atomic variables (not divided), small data structures, and pointers to the variable PGA.

The Variable PGA is a heap. Its chunks can be viewed from the fixed table x$ksmpp, which has the same structure as the X$ksmsp mentioned earlier. PGA heap contains some permanent memory for fixed table, It has dependencies on the settings of some parameters. These parameters contain db_files,log_files,control_files.



The UGA:

UGA (User Global area) contains information about a specific session, as follows:

The region of the duration and elapsed time of the cursor being opened

The state information of the package, the specific variable

Java Session State

can use the roles

Tracked events that are enable

The NLS parameter settings that work

Open Dblink.

Entry control for a session

Like the PGA, UGA is also made up of two areas: Fixed UGA and Variable UGA, also known as UGA HEAP. The Fixed UGA contains approximately 70 atomic variables, a small data structure, and pointers to variable UGA.

Chunks in UGA heap can obtain relevant information from their own sessions by viewing the table X$ksmup, which is the same structure as X$ksmsp. UGA heap contains some permanent memory segments about fixed tables. has dependencies on the settings of some parameters. These parameters are Open_cursors,open_links, and max_enable_roles.

The location of the UGA in memory depends on how the session is configured. If the session connection is configured in a dedicated server mode (DDS) that is a session corresponding to a process, the UGA is placed in the PGA. In the PGA, the Fixed UGA is one of the chunk, and UGA Heap is a sub heap (subheap) of the PGA. If the session connection is configured as Shared server mode (MTS), the Fixed UGA is a chunk in the shared pool, and UGA Heap is the Zishi in the shared pool (subheap)



The CGA:

Unlike other global zones, the call global area is transient. It only exists during the invocation of data, typically at the lowest level of an instance, when CGA is required, as follows:

Parsing an SQL statement

Execute an SQL statement

Take out the output of a SELECT statement

A single CGA is required when recursive calls are made. In the analysis of SQL statements, recursive calls to data dictionary information are required because of the parsing of SQL statements and the execution plan to be computed during the optimization of statements. Execute pl/ SQL blocks are also required to be called recursively when processing SQL statements, and recursive calls are required to handle trigger execution when the DML statement is executed.

Whether UGA is in the PGA or in the SGA, CGA is a sub heap (subheap) of the PGA. An important corollary of this fact is that during a call the session must be a process. It is important to understand this in the application development of an MTS Oracle database process. If the corresponding calls are more, you have to increase the number of processes to accommodate the increase in the call.

Without the data structure in CGA, calls cannot work. In fact, the data structures associated with a call are typically placed in UGA, such as SQL area,pl/sql area and sort area, which must be in UGA, Because they have to exist and be available between the calls. And the CGA contains data structures that you can release at the end of a call. For example, CGA contains information about recursive calls, direct I/o buffer, and other temporary data structures.

Java call memory is also in CGA. This section of memory is more tightly managed than other memory segments of Oracle. It is divided into three space:stack spaces, new spaces, old spaces. In new space and old Space is no longer referenced in the use of chunks, according to their length and size during the use of the different, in the implementation of the call will be used as a chunks collection. New Space Chunks many times the unused chunks collection process is not collected chunks will be placed in the old space chunks. This is the only one waste collection (garbage collection) in Oracle memory management, Other Oracle memory segments are released dead Chunks.



Process Memory Allocation

Unlike the SGA, the SGA is fixed after the instance is started, and the size of the PGA increases. By using malloc () or SBRK () The system is called to increase the size of the PGA by increasing the heap data segments for the process. New virtual memory for the OS will be added to the PGA as a new area in the PGA heap. These areas are typically only a few KB large, and Oracle will allocate thousands of areas if necessary.

The operating system has limits on the growth of the heap data segments for each process. Most of the cases are the operating system's memory parameters are limited (kernel parameter:maxdsiz), and there are some situations where the default value can be modified with each process as the benchmark. For all processes, The operating system also has a system-wide limit to the entire virtual memory, which is related to the system's swap space. Once these two restrictions are exceeded, Oracle's process encounters a ORA-4030 error in execution.

ORA-4030 This error is usually not due to the resource constraints of each process, but to the lack of space in swap spaces. To diagnose this problem, you can use some of the operating system's options to view the usage of swap. In addition, in some operating systems, Oracle contains a tool called Maxmem that can be used to see the maximum size of the heap data segments that each process can allocate and which limit is exceeded for the first time.

If this problem arises because the swap space is low and the number of pages changed is very frequent and numerous, you need to reduce the use of virtual memory at the system level, which can be reduced by reducing the amount of processes or by reducing the memory limit for each process. If the page shift is infrequent and less frequent, You need to increase the size of swap space.



Process Memory deallocation:

Oracle heap growth is easier than their shrinkage, and of course their size can shrink. In V$mystat and V$sesstat views, session statistics session UGA memory and session PGA Memory shows the current session's UGA and PGA memory sizes, including the internal free space. Corresponding statistics session UGA memory Max and session PGA memory Max shows the maximum number of UGA and the largest PGA that were used during session lifetime.

The UGA and PGA shrink only after a specific operation, such as a disk-sorted merge operation, or a program dbms_session. Free_unused_user_memory shows free memory. Only the entire free heap extent is released to the parent heap or the process heap data segment, so a portion of the internal free space still exists in the subheap after the memory is released.

In most operating system environments, Oracle does not reduce the process heap data segments nor release virtual memory and return it to the operating system. So from an operating system view, an Oracle process will retain the virtual memory size as a HWM. If necessary, Oracle will page out some of the unused virtual memory pages. For this reason, the operating system statistics for the virtual memory page of the Oracle process are difficult to understand. Therefore, the general use of Oracle Intrastat information to replace the use of operating system statistics.

Program Dbms_session. Free_unused_user_memory can only be used if the connection is an application that is configured as MTS. This is best used sparingly because it only frees the memory occupied by the large packet's array variable to be returned to large pool or shared pool. Generally, UGA heap memory should be released first, either by assigning a new empty array to the array variable or by calling the program dbms_session. Reset_package.












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.