Re: Does Oracle PGA take out memory out of SGA?

From: Mladen Gogala <gogala.mladen_at_gmail.com>
Date: Thu, 1 Apr 2021 00:10:11 -0400
Message-ID: <24de5993-7281-8d78-2181-a36970d35bac_at_gmail.com>


ORA-7445 is an Oracle bug, by definition. You should open a service request with Oracle Support. Other than that, shared memory is an operating system trick. Virtual memory is based on page tables. There is a table somewhere in the OS which contains virtual addresses and their translations. Translation can be an address of a physical page in RAM or can be a page in a page file. If two processes map the same  page table into their address space, we talk of shared memory. Yes, there are some details about that, such mapping is performed by shmat  system call and not by sbrk, malloc or calloc. Shared memory is used for SGA. You can see the shared memory on your system by using ipcs -m.

PGA, on the other hand, is allocated from the process private memory. That means that PGA consists of segments which are only mapped to a single process. PGA is allocated using sbrk, malloc or calloc. If PGA is expanded beyond limits, it will eventually hit another segment or OS limit and produce SIGSEGV "segmentation violation" signal and produce ORA-04036. Note that ORA-4036 is NOT the same as ORA-7445. ORA-7445 is a bug which needs to be resolved by Oracle Support. If you want to learn the basics of the Linux operating system, I would recommend 2 books:

  1. Understanding the Linux Kernel by Daniel Bovet
  2. Modern Operating Systems by Andrew Tannenbaum

Both books are available on Amazon. Of course, the unspoken prerequisite for both books is certain book by Kernighan & Ritchie which should be taught to K12 children (ANSI edition, of course). What you are asking is quite complex to explain. The usual answer is that PGA and SGA are "two different types of memory" but I don't find that answer satisfactory. In order to understand the memory handling on Linux, you would need to understand interrupts, paging, processes, page tables, address spaces and IPC (Inter-Process Communication). PGA is allocated from the process private address space, SGA is allocated from shared memory. Now what is private memory space, how does Linux manage it, what is a page fault and other questions are rather difficult to explain. Of course, you are the only person who can decide whether you need deep knowledge of the Linux or not.

On 3/31/21 3:03 PM, Amit Saroha wrote:
Dear All,

Please help me understanding PGA and SGA.

I was under the impression that PGA and Memory and SGA Memory are differently allocated. But, in a recent situation, we observed ORA-7445 [kghalf] and my DBA is saying - out of a total of 256 GB system memory one session's PGA consumed everything and only 8 MB was left for other sessions. But, apart from one process, no other processes were impacted so I have doubt that - Oracle consumes SGA memory and Allocates it to PGA of a single process.

Please help me understand.
-- 
Mladen Gogala
Database Consultant
Tel: (347) 321-1217
https://dbwhisperer.wordpress.com
-- http://www.freelists.org/webpage/oracle-l Received on Thu Apr 01 2021 - 06:10:11 CEST

Original text of this message