The Process Memory:
In addition to SGA (SYSTEM GLOBAL AREA), the Oracle process also uses the following three global districts:
The Process Global Area (PGA)
The User Global Area (UGA)
THE CALL GLOBAL AREA (CGA)
Many people don't know the difference between the PGA and UGAs. In fact, the difference between the two is similar to one process and a session. Although the process and session is generally a pair One relationship, but it is actually more complicated than this. A very obvious situation is MTS configuration, and the session is often much more than the process. Under this configuration, there will be a PGA in each process, each session will have one The information contained in the UGA.pga is not associated with the session, and the information contained in the UGA is based on a specific session.
THE PGA:
Process Global Area can also be understood as Process Global Area. Its memory segment is in the process private memory instead of shared memory. It is a global zone. It means that it contains all the codes that have the global variables and data structures that can enter, but it is not shared by all processes. Each Oracle server process contains its own PGA, which only contains specific specific specifications Information. The structure in PGA does not need to be protected by Latches because other processes cannot be accessed here.
The PGA contains the operating system resource information and the status information of the process being used, while other processes used in the Oracle shared resources in SGA. PGA is private rather than sharing, this mechanism is necessary Since the resource can be cleared and released when the process is dead.
The PGA includes two main areas: Fixed PGA and Variable PGA or PGA HEAP. Fixed PGA's role is similar to the Fixed SGA, which contains atomic variables (inseparable), 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 the X $ KSMSP mentioned in front. PGA Heap contains some permanent memory for Fixed Table, it There is a dependency on the settings of certain parameters. These parameters include db_files, log_files, control_files.
The UGA:
UGA (User Global Area) contains information about specific sessions, there are some following:
The persistent and running time of the cursor opened
Package status information, specific variable
Java session state
Can use Roles
Tracking events by enable
Enact NLS parameter settings
Open DBLINK
Entrance control of the session
Like PGA, UGA is also composed of two districts: Fixed UGA and Variable UGA, also known as UGA Heap. The Fixed UGA contains approximately 70 atomic variables, small data structures, and pointers to the Variable UGA.
Chunks in UGA HEAP can get information from their own sessions to get relevant information by viewing table x $ ksmup. The structure of this table is the same .uga heap contains some permanent memory segments about Fixed Tables, followed by The settings of the parameters have dependencies. These parameters have Open_CURSORS, OPEN_LINKS, and MAX_ENABLE_ROLES.
The location of the UGA depends on the session in memory. If the configuration method of the session connection is a dedicated server mode (DDS) is a session corresponding to a process, the UGA is placed in the PGA. In PGA, the Fixed UGA is One of the CHUNKs, and UGA HEAP is a subtle of PGA. If the session connection is configured to share server mode (MTS), the Fixed UGA is a CHUNK in Shared Pool, and UGA Heap is Shared Pool Subheap
The CGA:
Unlike other global districts, Call Global Area is transient. It is only necessary to CGA only when the data is called, which is usually required when calling the minimum level of the instance, as follows:
Analyze a SQL statement
Execute a SQL statement
Removing a SELECT statement is required when recursive calls are recursive. During the analysis of the SQL statement, the recursive call to the data dictionary information is required, because the SQL statement is to be syntax, and there is a statement During the optimization, the execution plan is to be calculated. When executing the execution of the PL / SQL block, it is also necessary to recurrent call when executing the SQL statement. When the execution of the DML statement is executed, it is necessary to recurrent call.
Whether UGA is placed in the PGA or in SGA, CGA is a subtle of PGA. An important inference of this fact is that the session in a call must be a process. For Oracle Database Process in an MTS It is important to understand this in this development. If there is more corresponding calls, you have to increase the number of processes to adapt to the increase in calls.
There is no data structure in the CGA, and Calls is not working. In fact, the data structure associated with a CALL is generally in UGA, such as SQL Area, PL / SQL Area and Sort Area, they must be in UGA, Because they have to be present and available between the Calls. The data structure included in the CGA is to be released after the end of the CALL. For example, the CGA contains information about recursive calls, direct I / O buffer, etc. There are other temporary data structures.
Java Call Memory is also in CGA. This paragraph is managed more densely than other memory segments of Oracle. It is divided into three Space: Stack Space, New Space, Old Space. No longer referenced in New Space and Old Space. Chunks, depending on the length and size of the period, the CHUNKS that is not used in the execution of the call. New Space Chunks will not be collected during the repeated collection of Chunks many times. Put it in Old Space Chunks. This is a unique waste collection in Oracle Memory Management, and other Oracle memory segments are released CHUNKS.
Process Memory Allocation
Unlike SGA, SGA is already fixed after the instance is started, and the size of the PGA will grow. By using the malloc () or SBRK () system call to increase the stack data segment size to the process PGA's size growth. The new virtual memory of the OS will be added as a new area in PGA HEAP. These areas are generally only a few KB, and Oracle will assign thousands if necessary. Area.
The operating system is limited to the growth of the heap data segments of each process. Most of the case is the memory parameter of the operating system to limit the system of kernel parameter: MaxDsiz, and some of its default is available in each process. For the benchmark. For all processes, the operating system also has a system global limit on the entire virtual memory. This limit is related to the system's SWAP Space. Once these two restrictions, Oracle's process will encounter in the execution. Go to ORA-4030 error.
ORA-4030 This error is generally not because the resource limit of each process is due to the deficiencies of SWAP Space. In order to diagnose this issue, some options can be used to view SWAP Space usage. In addition, in some operating systems In the middle, Oracle contains a tool called MaxMem, which can be used to see the maximum size of the heap data segment that can be assigned by each process and which limit is the first time.
If the appearance of this problem is because the SWAP Space is insufficient, and the movement of the page is very frequent, it is necessary to reduce the virtual memory of the system level, which can be reduced by reducing the number of processes. Restrictions. If the change is not frequent and less, you need to zoom SPAP SPACE SIZE.
Process Memory Deallocation:
The growth of Oracle is easier than their contract, of course, their size can also be contracted. In V $ MyStat and V $ SESSSTAT view, SESSION's statistics session UGA Memory and Session PGA Memory show current session UGA And the memory size of the PGA, including internal free space. The corresponding statistics session UGA MEMORY MAX and SESSION PGA Memory Max showed the largest UGA and the largest PGA.uga and PGA in the SESSION survival, respectively. The specific operation will only shrink, such as a disk sorted merge operation, or using the program dbms_session.free_unused_user_memory display release memory. Only the entire Free Heap Extent will be released to the parent, or the process heap data, there is a part Internal Free Space still exists in SubHeap after memory release.
In most operating system environments, Oracle does not reduce the process heap data segment and will not release virtual memory and return it to the operating system. So from an operating system view, an Oracle process will put virtual memory SIZE is reserved as HWM. If necessary, Oracle will go out of some virtual memory pages that are not used. Because this reason, the operating system statistics about the virtual memory page of Oracle process is difficult to understand. Therefore, it is generally used to replace statistics for the use of the operating system in place of the Oracle internal statistics.
Program dbms_iession.free_unused_user_memory can only be used by applications configured as MTS mode. This is best to use less because it only releases the memory return of the large package of Array variables to Large Pool or Shared pool. On the ground, the memory of the UGA HEAP should be released first, and can be used by assigning new email array to the Array variable, or by calling program dbms_session.reset_package.