PL/SQL Program Units即PL/SQL程序单元，常被叫做”library units”或lib-units.
- package spec
- package body
- top-level function or procedure
- type spec
- type body
- anonymous blocks.
- PL/SQL stack call,用于保存本地变量和其他一些状态结构
- 二级内存(secondary memory),分配的堆和大的可收缩本地变量如大的strings、Lob或collections
- 程度单元的实例(library-unit instantiations),如package global variables, DL0/ DL1 dependency vectors, display frame等
KGL – Kernel Generic Library Manager
该layer管理会话间需要共享的资源,如PL/SQL MCODE,Diana,Source,SQL cursor,SQL Plan)
KGI – Kernel Generic Instantiation Layer.
KOH/KGH 该layer用以管理heap service堆服务
PLSQL MCODE Heap的属性
- machine dependent binary format for a compiled PL/SQL library-unit.
- to execute code in a lib-unit, its MCODE heap must be loaded in memory.
- MCODE is loaded in SGA and is “pinned” for CALL duration.
- once unpinned, the heap may be aged; hence, may need to get re-loaded.
- important to page large data structures in SGA.
MCODE Heap: Subcomponents
- EntryPoint Piece (PL_UEP)
- Code Segment or Byte Code Piece (PL_UCP)
- Constant Pool:
- Data Segment (PL_UKP)
- Handle Segment (PL_UHS)
- SQL Strings Table (PL_USP)
- When a lib-unit is first referenced by a program (session) an instantiation of the lib unit is created.
- PL/SQL relies on KGI for inst obj mgmt.
- A PL/SQL lib-unit instantiation consists of:
- PLIO struct (the handle of the PL/SQL inst obj)
- Static Frame
- Secondary (Heap) Memory for package globals
- PLIO Struct
- first portion of PLIO struct is the KGIOB struct (kgi’s portion of the object handle)
- points to the static frame struct (PLIOST)
- also contains other book-keeping info (such as memory duration of instantiation’s work area, etc.)
- Static Frame:
- represents that part of instantiation’s work area whose size is compile-time determined.
- the root of the static frame is PLIOST struct which leads the following sub-pieces:
- depends-on array to global variable vectors (DL0)
- depends-on array to other instantiations (DL1)
- Display Frame (DPF)
- global variable vector for this unit (GF)
- primary memory for global variables.
- Secondary Memory for package globals
- used to allocate data types that are stored out-of-line (heap allocated)e.g., collections, large strings, large records, LOBs, datetime types, etc.