More Related Content Similar to All Oracle DBAs have to know about Unix Memory Monitoring (20) More from Yury Velikanov (6) All Oracle DBAs have to know about Unix Memory Monitoring1. All Oracle DBAs have to know about
Unix Memory Monitoring
2006-11-14
Copyright © 2005 TietoEnator Corporation
2. Example 1
Copyright © 2004 TietoEnator Corporation
3. Example 2
Copyright © 2004 TietoEnator Corporation
4. Example 3
Copyright © 2004 TietoEnator Corporation
5. Main questions …
Do I have a memory shortage ?
How many memory is utilized currently ?
Why answers are not obvious?
Doesn't focus on particular Unix platform
Gives general idea of memory management
Copyright © 2004 TietoEnator Corporation
6. Content
Concepts of Unix memory management
– Single process virtual address space & main components
– Unix swap subsystem
– Unix system memory components
– Why it is difficult to say how many memory is utilized
Possible answers
– Do I have a memory shortage ?
– How many memory is utilized currently ?
Oracle & Memory utilization
Copyright © 2004 TietoEnator Corporation
7. Single process virtual address space
“Dream world”
00000000 0x00000000
TEXT (CODE)
- 175MB - - 175MB -
0AEA8000 0x0AEA8000
TEXT Variable part
0AEA8000 0x0AEA8000
HEAP (PGA)
- 849 MB- - 849 MB-
40000000 0x40000000
Dynamically loaded
40000000 0x40000000
Libraries (CODE)
- 256 MB - - 256 MB -
DLL Variable part
50000000 0x50000000
Shared Memory
BFFE3000(1,75GB) 0xBFFE3000(1,75GB)
Stack area +
FFFFFFFF (1GB) 0xFFFFFFFF (1GB)
DEMO
pmap
Copyright © 2004 TietoEnator Corporation
8. Single process virtual memory
“Dream world”
Components order and size of memory regions are dependent on used
platform and Oracle version
Main components
– Text (constant/variable parts)
oracle – executable in case of client process
– Heap
PGA – Program Global Area
– Sort/Hash area
– Program variables
– Libraries (constant/variable parts)
OS/Oracle libraries
Example: JVM libraries in case of java call within DB
– Shared Memory
SGA (shared pool, buffers cache, etc)
– Stack area
Each area have strict boundaries for current installation/configuration
Copyright © 2004 TietoEnator Corporation
9. Single process virtual memory translation
“Dream world” “Real World”
RAM on DB Server
Random Access Memory
00000000
TEXT (CODE)
- 175MB -
0AEA8000
TEXT Variable part
0AEA8000
HEAP (PGA)
- 849 MB-
40000000 VM
Dynamically loaded Translation
40000000
Libraries (CODE)
- 256 MB -
DLL Variable part
50000000
Shared Memory
BFFE3000(1,75GB)
Stack area +
FFFFFFFF (1GB)
SWAP Space on disk FS
Copyright © 2004 TietoEnator Corporation
10. Single process virtual memory translation
Single process see continues memory space
OS translate process space to physical locations
Some parts of virtual process space are shared across all
running processes
– OS/Oracle code
– SGA
Some memory areas are private for each process
Copyright © 2004 TietoEnator Corporation
11. Single process virtual address space
One copy per process (W) One copy per server (R/O)
TEXT (CODE)
TEXT Variable part
HEAP (PGA)
Dynamically loaded
Libraries (CODE) One copy per Instance (W)
DLL Variable part
Shared Memory
Stack area
Copyright © 2004 TietoEnator Corporation
12. Main memory consumption areas
Process Private Area (W) Static Code (R/O)
PGA Oracle executables
Runtime size is variable Runtime size is constant
Shared Memory (W)
Oracle SGA
Runtime size is constant
Copyright © 2004 TietoEnator Corporation
13. RAM utilization and swap subsystem
“Real World”
RAM (size is limited)
Process Private Area (W) Static Code (R/O)
PGA Oracle executables
……..
Runtime size is variable Constant Size
Shared Memory (W)
Oracle SGA
Runtime size is constant
Swap Process Swap out
Swap in
Disk
SWAP Space FS
Copyright © 2004 TietoEnator Corporation
14. Swap subsystem
Allow processes to utilize more memory then available in the system
Swap process swap out inactive parts of the memory
On some platforms OS reserve swap space at the time RAM area is
allocated
– This is why Oracle recommends to create 2 times swap space
then RAM installed on the server
– Because of that used Swap space can’t be used as general
indicator of memory shortage
Intensive swap out-s is good indicator of memory shortage
Copyright © 2004 TietoEnator Corporation
15. RAM utilization and swap subsystem
“Real World”
RAM (size is limited)
Process Private Area (W) Static Code (R/O)
PGA Oracle executables
……..
Runtime size is variable Constant Size
Shared Memory (W)
Oracle SGA
Runtime size is constant
Swap Process Swap out
Swap in
Disk
SWAP Space FS
Copyright © 2004 TietoEnator Corporation
16. Resident size of the process (RSS)
00000000
TEXT (CODE)
- 175MB -
0AEA8000 SWAP
TEXT Variable part
0AEA8000 or
HEAP (PGA)
- 849 MB-
40000000 DISK
RAM
Dynamically loaded
40000000
Libraries (CODE)
- 256 MB - or
DLL Variable part
50000000
NOT
Shared Memory
BFFE3000(1,75GB) ALLOCATED
Stack area
FFFFFFFF (1GB)
Copyright © 2004 TietoEnator Corporation
18. Resident size of the process (RSS)
RSS Part
00000000
TEXT (CODE)
- 175MB -
0AEA8000
TEXT Variable part
0AEA8000
HEAP (PGA)
- 849 MB-
40000000
Dynamically loaded
40000000
Libraries (CODE)
- 256 MB -
DLL Variable part
50000000
Shared Memory
BFFE3000(1,75GB)
Stack area
FFFFFFFF (1GB)
VSIZE Part
Copyright © 2004 TietoEnator Corporation
19. How many memory utilized? [OS view]
OS Tools reflect different information on different platforms
In general ps, top and other utilities
– doesn’t reflect Size of Process Private area correctly
– Include shared parts of the process
We can’t get figure how many memory utilized by adding
all RSS or VSIZE values
pmap like utility can be used (on single process basis)
Copyright © 2004 TietoEnator Corporation
20. Unix system memory components
Server dedicated to run Oracle Instance
RAM
Process Private Area (W) Static
PGA Code
…….. (R/O)
Kernel Runtime size is variable
Oracle
& exe File System
System Shared Memory (W) Constant Buffers
Processes Oracle SGA Size
Runtime size is constant
Copyright © 2004 TietoEnator Corporation
21. How many memory is free? [OS View]
Can we rely on free memory figure from top and others tools?
The file system cache uses all available free memory to buffer files
on the file system
On most systems, the amount of free memory is almost zero
file system cache used memory freed first of all if there are memory
shortage
Free memory figure doesn’t represent available memory in the system
Copyright © 2004 TietoEnator Corporation
22. Do I have a memory shortage ?
Free memory indicator
– Because of file system cache almost useless
– If free memory is close to 0 don’t worry
Swapping activities
– One of the best OS level indicators
– Swap out (so), Page out (po), Scan-rate (sr)
Copyright © 2004 TietoEnator Corporation
23. How many memory is utilized currently ?
Constant memory areas
– Kernel & OS Processes
– Static Code (executables & libraries)
– Shared Memory (SGA)
Variable memory areas
– File System Buffers (freed on demand)
– Process Private Area (PGA)
RAM
Process Private Area (W) Static
PGA Code
…….. (R/O)
Kernel Runtime size is variable
Oracle
& exe File System
System Shared Memory (W) Constant Buffers
Processes Oracle SGA Size
Runtime size is constant
Copyright © 2004 TietoEnator Corporation
24. How to see used PGA size?
Easily can be retrieved from database
Tuned using DB parameters
– pga_aggregate_target
– sort_area_size/hash_area_size
– SGA
Copyright © 2004 TietoEnator Corporation
25. Oracle & Memory utilization
In general Oracle doesn't return used memory back to OS
Shared server configuration
– UGA located in shared pool PGA is NOT !
– Single call runtime variables located in PGA
Background processes
– Job processes
– Parallel processes
SGA_MAX_SIZE
– Oracle Reserves memory straight after instance startup
Oracle on 32bit platform
– Can’t address more then 4GB memory
– By default 1.7GB big SGA allowed, increase up to 2.7 GB (Note:200266.1)
– Very Large Memory (VLM) up to 64GB (Note:260152.1)
Heapdump could be used to troubleshoot memory related problems
– oradebug dump heapdump 5 (Note:174555.1)
Copyright © 2004 TietoEnator Corporation
26. Conclusion
Do I have a memory shortage ?
– Free memory is not a good metric
– Swap size not always good to consider
– Swap outs is one reliable indicator
How many memory is utilized currently ?
– Difficult to see from Unix side
– Variable part could be retrieved from Oracle
– There some problems to consider
Copyright © 2004 TietoEnator Corporation
27. Thank you for your attention …
Q&A
Copyright © 2004 TietoEnator Corporation
28. Tools to calculate memory usage [OS View]
ipcs : Shared memory information
ipcs -m
pmap : Memory map for a particular process
pmap <pid> [cat /proc/<pid>/maps]
ps : Memory information for list of the processes
ps -u oraenv01 -o pid,vsize,rss,cmdtop
top : General memory utilization information
top [cat /proc/meminfo]
vmstat, sar : Swap activities indicators
Copyright © 2004 TietoEnator Corporation
Editor's Notes From: oracle-l-bounce@xxxxxxxxxxxxx [mailto:oracle-l-bounce@xxxxxxxxxxxxx] On Behalf Of Seema Singh Sent: Thursday, May 06, 2004 3:46 PM To: oracle-l@xxxxxxxxxxxxx Subject: How much Max oracle memory (SGA)can be allocated on SUN SOLARIS if RAM =1.5gb Hi How much maximum SGA we can allocate if MEMORY on SUN Solaris is 1.5gb? When sga alloacted to 220mb, top command show 46mb free.when I bumped sga to 225mb it's still showing 46m is free. thx-seema ANSWER: Seema It is quite normal to have free memory to hover around this low. Read on if you are interested in knowing why. From Solaris 2.6 onwards Virtual Memory Manager will use as much as memory available, to benefit file system random IO. If you have heavy random file system activity then the memory can be filled with these file pages. This might not be well suited for database environments. Paging kicks-in when free memory falls below lotfree kernel parameter. Swapping and paging, can page out the process exec pages, heap and stack, even though the physical memory is filled with file pages (Whether SGA can be swapped/paged depends upon ISM-Intimate Shared Memory use, as the shared memory segments are locked if ISM is used ). This can create application performance issues, including database performance issues. Both background and server processes are susceptible to be paged out, if there is massive random IO. Solaris 2.6+ introduced priority_paging to alleviate this. If priority paging is enabled, then the paging daemon pages the file pages when the free memory falls below a new parameter cachefree which is higher than lotfree. This paging will differentiate between file pages and anonymous pages and so the file pages will be paged out before process' pages are considered. Solaris 2.8 introduces cyclical page cache, where the file and anonymous pages are handled differently. So, this issues should not exists in 2.8. Point is, as long as you have priority_paging enabled in 2.6, (In 2.7 it is enabled by default) you don't need to be concerned. I would be concerned only if there is paging/swapping for anonymous pages. Memstat can tell you what is being paged/swapped, if you are in 2.8. I am not suggesting you to increase the SGA, by any means. That shoud be decided by database/app behavior, not just by this.. HTH Thanks Riyaj "Re-yas" Shamsudeen Certified Oracle DBA