05.11.2015 Views

Apress.Expert.Oracle.Database.Architecture.9i.and.10g.Programming.Techniques.and.Solutions.Sep.2005

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CHAPTER 4<br />

■ ■ ■<br />

Memory Structures<br />

In this chapter, we’ll look at <strong>Oracle</strong>’s three major memory structures:<br />

• System Global Area (SGA): This is a large, shared memory segment that virtually all<br />

<strong>Oracle</strong> processes will access at one point or another.<br />

• Process Global Area (PGA): This is memory that is private to a single process or thread,<br />

<strong>and</strong> is not accessible from other processes/threads.<br />

• User Global Area (UGA): This is memory associated with your session. It will be found<br />

either in the SGA or the PGA depending on whether you are connected to the database<br />

using shared server (then it will be in the SGA), or dedicated server (it will be in the<br />

PGA, in the process memory).<br />

■Note In earlier releases of <strong>Oracle</strong>, shared server was referred to as Multi-Threaded Server or MTS. In this<br />

book, we will always use the term “shared server.”<br />

We’ll first discuss the PGA <strong>and</strong> UGA, <strong>and</strong> then we’ll move on to examine the really big<br />

structure: the SGA.<br />

The Process Global Area <strong>and</strong> User Global Area<br />

The PGA is a process-specific piece of memory. In other words, it is memory specific to a<br />

single operating system process or thread. This memory is not accessible by any other<br />

process/thread in the system. It is typically allocated via either of the C runtime calls malloc()<br />

or memmap(), <strong>and</strong> it may grow (<strong>and</strong> shrink even) at runtime. The PGA is never allocated in<br />

<strong>Oracle</strong>’s SGA—it is always allocated locally by the process or thread.<br />

The UGA is, in effect, your session’s state. It is memory that your session must always be<br />

able to get to. The location of the UGA is wholly dependent on how you connected to <strong>Oracle</strong>.<br />

If you connected via a shared server, then the UGA must be stored in a memory structure that<br />

every shared server process has access to—<strong>and</strong> that would be the SGA. In this way, your session<br />

can use any one of the shared servers, since any one of them can read <strong>and</strong> write your<br />

session’s data. On the other h<strong>and</strong>, if you are using a dedicated server connection, this need for<br />

universal access to your session state goes away, <strong>and</strong> the UGA becomes virtually synonymous<br />

with the PGA; it will, in fact, be contained in the PGA of your dedicated server. When you look 115

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!