Home > Back-end >  Memory management in the System Global Area(SGA)
Memory management in the System Global Area(SGA)

Time:01-14

It's correct to say that the SGA will always allocate server memory when starting an instance, as well as it will always deallocate server memory when closing an instance?

Thanks for the help !

Marcos.

I would like to understand the concept

CodePudding user response:

Yes, when you start an instance, a shared memory segment will be allocated the size of sga_max_size. All Oracle processes will attach to this shared memory segment. When you shut the instance down, the memory is released.

While the instance is running, SGA memory is managed either statically (by setting the various *size parameters) or dynamically (by setting sga_target). This drives the reassignment of memory from one SGA component to another, for example, between the shared pool and the buffer cache. This happens on demand or on the fly, either manually or automatically. But the overall total "pool" of memory it has to work with is hard-capped for the life of the instance at sga_max_size. To change that requires changing the init parameter and bouncing the instance.

Keep in mind that Oracle processes also have PGA/UGA, which is privately allocated memory each process will malloc as needed and release when not needed. Obviously when a process exits it releases any of its private memory.

CodePudding user response:

Well, yes and no. SGA is located in shared memory segments. So you can list them using ipcs command in Linux. The whole size of SGA reserved by Oracle from Linux kernel during startup. Whatever "reserved" means today. You can see it in alert.log or in /proc/meminfo if you use hugepages.

Then RAM is allocated lazily by kernel each time Oracle touches some pages in shared memory segment. If you really need to allocate SGA during startup you have to use paremeter pre_page_sga

PRE_PAGE_SGA determines whether Oracle reads the entire SGA into memory at instance startup. Operating system page table entries are then prebuilt for each page of the SGA. This setting can increase the amount of time necessary for instance startup, but it is likely to decrease the amount of time necessary for Oracle to reach its full performance capacity after startup.

If you shutdown Oracle correctly all shared memory segments should be released. Again you can validate it using ipcs command.

  • Related