Application of Process Memory in Oracle Storage Structure

Source: Internet
Author: User

The following articles mainly describe the actual application of Process Memory in the Oracle storage structure. We all know the actual application processes of Oracle except for the SGA (System Global Area, the following three global zones are also frequently used:

The Process Global Area (PGA );

The User Global Area (UGA );

The Call Global Area (CGA ).

Many people do not know the difference between PGA and UGA. In fact, the difference between the two is similar to that between a process and a session. Although process and session are generally one-to-one relationships, they are actually more complicated than this. One obvious case is that MTS is configured, and there are usually more sessions than processes. In this configuration, each process has a PGA, and each session has a UGA. The information contained in PGA is not associated with the session, and the information contained in UGA is based on the specific session.

The PGA: Process Global Area (PGA) can be understood as Process Global Area or Program Global Area. Its Oracle Memory segment is in the Process Private Memory area rather than the Shared Memory area ). It is a global zone, which means that it contains all the global variables and data structures that code may enter, but it is not shared by all processes.

Each Oracle Server process contains its own PGA, which only contains specific information about the process. The structure in PGA does not need to be protected by latches, because other processes cannot access it.

PGA contains information about the operating system resources used by the process and the status of the process, while the Oracle shared resources used by other processes are in SGA. PGA is private rather than shared. This mechanism is necessary because these resources can be cleared and released when the process dies.

PGA contains two major areas: Fixed PGA and Variable PGA, or PGA Heap. The role of Fixed PGA is similar to that of Fixed SGA. They both contain atomic variables (which cannot be divided), small data structures, and pointers to Variable PGA.

Variable PGA is a heap. Its Chunks can be viewed from Fixed Table X $ KSMPP. The structure of this Table is the same as that mentioned above. Pga heap contains some permanent memory related to Fixed Table, which is dependent on some parameter settings. These parameters include DB_FILES, LOG_FILES, and CONTROL_FILES.

The UGA: UGA (User Global Area) contains information about a specific session, which includes The following:

The duration and running time of the opened cursor;

Package status information, specific variables;

Java session status;

Available ROLES;

The tracking event of the ENABLE;

NLS parameter settings;

DBLINK opened;

Session entry control.

Like PGA, UGA is also composed of two zones: Fixed UGA and Variable UGA, also known as uga heap. Fixed UGA contains about 70 atomic variables, small data structures, and pointers to Variable UGA.

The Chunks in uga heap can obtain relevant information from their own sessions by viewing the table X $ KSMUP. The structure of this table is the same as that of X $ KSMSP. Uga heap contains some permanent Oracle memory segments related to fixed tables, which are dependent on some parameter settings. These parameters include OPEN_CURSORS, OPEN_LINKS, and MAX_ENABLE_ROLES.

The location of UGA in the memory depends on the session configuration method. If the session connection is configured in the private server mode (DDS), that is, a session corresponds to a process, then the UGA is placed in the PGA. In PGA, Fixed UGA is one of the chunks, while uga heap is a sub-HEAP of PGA ). If the session connection is configured as the SHARED Server mode (MTS), the Fixed UGA is a Chunk in the shared pool, and the uga heap is the Subheap in the shared pool)

The CGA:

Unlike other Global zones, Call Global Area is transient. It only exists during data calls. Generally, CGA is required for the lowest-level instance calls, as shown below:

Analyze an SQL statement;

Execute an SQL statement;

Extract the output of a SELECT statement.

A separate CGA is required for recursive calls. During the analysis of SQL statements, recursive calling of Data Dictionary information is required, because syntax analysis of SQL statements is required, and execution plans must be calculated during statement optimization. When executing PL/SQL blocks, you also need to call them recursively when processing SQL statements. When executing DML statements, you also need to call them recursively to process trigger execution.

CGA is a sub-heap of PGA, whether in PGA or in SGA ). An Important Inference of this fact is that a session must be a process during a call. It is important to understand this point when developing an MTS Oracle Database process application. If the number of corresponding calls is large, you need to increase the number of processes to adapt to the increase in the number of calls.

Without the data structure in CGA, cballs cannot work. In fact, the data structures related to a CALL are generally put in UGA, such as SQL area, PL/SQL AREA, and SORT AREA. They must all be in UGA, because they must always exist and be available between CILS. The data structure contained in CGA must be released after 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 memory segment is more intensive to manage than other Oracle memory segments. It is divided into three spaces: Stack Space, New Space, and Old Space. Chunks that are no longer referenced in New Space and Old Space are collected as unused Chunks during call execution according to their length and SIZE during use.

New Space Chunks the uncollected Chunks will be put into the Old Space Chunks during repeated Chunks collection. This is the only waste collection in Oracle memory management. Other Oracle memory segments release Dead Chunks.

 
 
  1. Process Memory Allocation  

Unlike SGA, the SIZE of SGA is fixed after the instance is started, and the SIZE of PGA increases. Increase the SIZE of the PGA by increasing the SIZE of the heap data segment for the process by calling the malloc () or sbrk () system. The new virtual memory of the OS will be added to the PGA as a new area in the PGA HEAP. These zones are generally several KB in size. If necessary, Oracle will allocate thousands of zones.

The operating system limits the growth of heap data segments for each process. In most cases, the memory parameters of the operating system are limited (kernel parameter: MAXDSIZ). In some cases, its default value can be modified based on each process. For all processes, the operating system also has a global system limit on the entire virtual Oracle memory, which is related to the system's swap space. Once these two limits are exceeded, Oracle processes encounter ORA-4030 errors during execution.

ORA-4030 errors are generally generated not because of the resource limits for each process, but because of insufficient swap space. To diagnose this problem, you can use some operating system options to view the usage of swap space. In addition, in some operating systems, Oracle contains a tool called maxmem, which can be used to view the maximum SIZE of heap data segments that each process can allocate and which limit is exceeded for the first time.

If this problem occurs because swap space is insufficient and page feed is frequently and frequently performed, You need to reduce the use of system-level virtual memory, this can reduce the number of processes or reduce the memory limit for each process. If the page change action is infrequent and relatively small, you need to increase the swap space size.

 
 
  1. Process Memory Deallocation:  

The growth of Oracle heap is easier than that of them, and their SIZE can also be reduced. In the V $ MYSTAT and V $ SESSTAT views, session uga memory and session pga memory show the memory size of the current session UGA and PGA, respectively, contains internal free space.

The corresponding statistical information session uga memory max and session pga memory max respectively show the largest UGA and largest PGA used during the session survival period.

UGA and PGA will contract only after a specific operation, such as a disk sort merge operation or a program DBMS_SESSION. FREE_UNUSED_USER_MEMORY: the memory is released. Only the entire free heap extent is released to the parent heap or the process heap data segment. Therefore, some internal free spaces still exist in subheap after the memory is released.

In most operating system environments, Oracle does not reduce the process heap data segment, nor release the virtual Oracle memory and return it to the operating system. Therefore, from an operating system view, an Oracle process will retain the virtual memory SIZE as HWM. If necessary, Oracle will swap out useless virtual memory pages.

For this reason, the operating system statistics on the Virtual Memory Page of the Oracle process are hard to understand. Therefore, Oracle internal statistics are generally used instead of operating system statistics.

Program DBMS_SESSION. FREE_UNUSED_USER_MEMORY can only be used when the connection is an application configured in MTS mode. It is best to use less, because it only releases the memory occupied by the array variable of the Large package and returns it to the Large Pool or the Shared Pool. Generally, the Oracle memory of uga heap should be released first. You can assign a new empty array to the array variable or call the program DBMS_SESSION. RESET_PACKAGE.

Article by: http://database.csdn.net/c_oracle/tag/2

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.