In an attempt to better demonstrate the presumable advantage of DISM, please, consider the following changes in the original sample source code 3.0:
037: std::size_t const size =
12UL * 1024UL * 1024UL * 1024UL;
051: void * p = ::shmat( id, 0, SHM_PAGEABLE );
063: if ( ::mlock( p, size / 4 ) == 0 )
069: ::memset( p, '*', size / 2 );
075: switch ( ::munlock( p, size / 4 ) )
$ getent user_attr
...::::defaultpriv=basic,proc_lock_memory;...
$ swap -lh; swap -sh
swapfile dev swaplo blocks free
/dev/swap - 4K 4.0G 3.9G
total: 500M allocated + 178M reserved = 676M used, 18G available
$ ipcs -mA
IPC status ...
T ... KEY ... NATTCH SEGSZ CPID ... ISMATTCH PROJECT
Shared Memory:
$ zonestat 1 1
Collecting data for first interval...
Interval: 1, Duration: 0:00:01
SUMMARY Cpus/Online: 24/24 PhysMem: 23.9G VirtMem: 27.9G
---CPU---- --PhysMem-- --VirtMem-- --PhysNet--
ZONE USED %PART USED %USED USED %USED PBYTE %PUSE
[total] 0.32 1.37% 8355M 34.0% 10.0G 35.9% 396K 0.01%
[system] 0.32 1.36% 8274M 33.6% 9.9G 35.5% - -
... 0.00 0.00% 81.0M 0.33% 116M 0.40% 228 0.00%
Getting shared memory.
Press <ENTER>
Success!
$ swap -lh; swap -sh
swapfile dev swaplo blocks free
/dev/swap - 4K 4.0G 3.9G
total: 500M allocated + 12G reserved = 13G used, 5.9G available
$ ipcs -mA
IPC status ...
T ... KEY ... NATTCH SEGSZ CPID ... ISMATTCH PROJECT
Shared Memory:
m ... 0x1 ... 0 12884901888 3832 ... 0 group.staff
$ zonestat 1 1
Collecting data for first interval...
Interval: 1, Duration: 0:00:01
SUMMARY Cpus/Online: 24/24 PhysMem: 23.9G VirtMem: 27.9G
---CPU---- --PhysMem-- --VirtMem-- --PhysNet--
ZONE USED %PART USED %USED USED %USED PBYTE %PUSE
[total] 0.26 1.11% 8378M 34.1% 22.0G 78.8% 711K 0.02%
[system] 0.26 1.10% 8296M 33.7% 9.9G 35.5% - -
... 0.00 0.00% 82.5M 0.33% 12.1G 43.2% 228 0.00%
$ prstat -c -p 3832 1 1
Please wait...
PID USERNAME SIZE RSS ...
3832 ... 5140K 2176K ...
...
Attaching to shared memory.
Press
Success!
$ swap -lh; swap -sh
swapfile dev swaplo blocks free
/dev/swap - 4K 4.0G 3.9G
total: 492M allocated + 12G reserved = 13G used, 5.9G available
$ ipcs -mA
IPC status ...
T ... KEY ... NATTCH SEGSZ CPID ... ISMATTCH PROJECT
Shared Memory:
m ... 0x1 ... 1 12884901888 3832 ... 1 group.staff
$ zonestat 1 1
Collecting data for first interval...
Interval: 1, Duration: 0:00:01
SUMMARY Cpus/Online: 24/24 PhysMem: 23.9G VirtMem: 27.9G
---CPU---- --PhysMem-- --VirtMem-- --PhysNet--
ZONE USED %PART USED %USED USED %USED PBYTE %PUSE
[total] 0.26 1.10% 8391M 34.1% 22.0G 78.8% 534 0.00%
[system] 0.26 1.09% 8308M 33.8% 9.9G 35.5% - -
... 0.00 0.00% 82.6M 0.33% 12.1G 43.3% 432 0.00%
$ prstat -c -p 3832 1 1
Please wait...
PID USERNAME SIZE RSS ...
3832 ... 12G 2176K ...
...
$ pmap -x 3832 | head
3832: ./shm_v04
Address Kbytes RSS ... Locked Mode Mapped File
0000000000400000 8 8 ... - r-x-- shm_v04
0000000000411000 8 8 ... - rw--- shm_v04
0000000000413000 160 68 ... - rw--- [ heap ]
FFFF80FC80000000 12582912 - ... - rwxs- [ dism ... ]
...
Locking shared memory.
Press <ENTER>
Success!
$ swap -lh; swap -sh
swapfile dev swaplo blocks free
/dev/swap - 4K 4.0G 3.9G
total: 3.5G allocated + 9.2G reserved = 13G used, 2.9G available
$ ipcs -mA
IPC status ...
T ... KEY ... NATTCH SEGSZ CPID ... ISMATTCH PROJECT
Shared Memory:
m ... 0x1 ... 1 12884901888 3832 ... 1 group.staff
$ zonestat 1 1
Collecting data for first interval...
Interval: 1, Duration: 0:00:01
SUMMARY Cpus/Online: 24/24 PhysMem: 23.9G VirtMem: 27.9G
---CPU---- --PhysMem-- --VirtMem-- --PhysNet--
ZONE USED %PART USED %USED USED %USED PBYTE %PUSE
[total] 0.29 1.23% 11.1G 46.6% 25.0G 89.5% 704K 0.00%
[system] 0.29 1.22% 8308M 33.8% 12.9G 46.2% - -
... 0.00 0.00% 3154M 12.8% 12.1G 43.3% 1347 0.00%
$ prstat -c -p 3832 1 1
Please wait...
PID USERNAME SIZE RSS ...
3832 ... 12G 3074M ...
...
$ pmap -x 3832 | head
3832: ./shm_v04
Address Kbytes RSS ... Locked Mode Mapped File
0000000000400000 8 8 ... - r-x-- shm_v04
0000000000411000 8 8 ... - rw--- shm_v04
0000000000413000 160 68 ... - rw--- [ heap ]
FFFF80FC80000000 12582912 3145728 ... 3145728 rwxs- [ dism ... ]
...
Using shared memory.
Press <ENTER>
Success!
$ swap -lh; swap -sh
swapfile dev swaplo blocks free
/dev/swap - 4K 4.0G 3.9G
total: 6.5G allocated + 6.2G reserved = 13G used, 2.9G available
$ ipcs -mA
IPC status ...
T ... KEY ... NATTCH SEGSZ CPID ... ISMATTCH PROJECT
Shared Memory:
m ... 0x1 ... 1 12884901888 3832 ... 1 group.staff
$ zonestat 1 1
Collecting data for first interval...
Interval: 1, Duration: 0:00:01
SUMMARY Cpus/Online: 24/24 PhysMem: 23.9G VirtMem: 27.9G
---CPU---- --PhysMem-- --VirtMem-- --PhysNet--
ZONE USED %PART USED %USED USED %USED PBYTE %PUSE
[total] 0.27 1.13% 14.1G 59.1% 25.0G 89.5% 228 0.00%
[system] 0.27 1.12% 8309M 33.8% 12.9G 46.2% - -
... 0.00 0.00% 6225M 25.3% 12.1G 43.3% 228 0.00%
$ prstat -c -p 3832 1 1
Please wait...
PID USERNAME SIZE RSS ...
3832 ... 12G 6146M ...
...
$ pmap -x 3832 | head
3832: ./shm_v04
Address Kbytes RSS ... Locked Mode Mapped File
0000000000400000 8 8 ... - r-x-- shm_v04
0000000000411000 8 8 ... - rw--- shm_v04
0000000000413000 160 68 ... - rw--- [ heap ]
FFFF80FC80000000 12582912 6291456 ... 3145728 rwxs- [ dism ... ]
...
Unlocking shared memory.
Press
Success!
$ swap -lh; swap -sh
swapfile dev swaplo blocks free
/dev/swap - 4K 4.0G 3.9G
total: 6.5G allocated + 6.2G reserved = 13G used, 5.9G available
$ ipcs -mA
IPC status ...
T ... KEY ... NATTCH SEGSZ CPID ... ISMATTCH PROJECT
Shared Memory:
m ... 0x1 1 12884901888 3832 ... 1 group.staff
$ zonestat 1 1
Collecting data for first interval...
Interval: 1, Duration: 0:00:01
SUMMARY Cpus/Online: 24/24 PhysMem: 23.9G VirtMem: 27.9G
---CPU---- --PhysMem-- --VirtMem-- --PhysNet--
ZONE USED %PART USED %USED USED %USED PBYTE %PUSE
[total] 0.30 1.27% 14.1G 59.1% 22.0G 78.8% 181K 0.00%
[system] 0.30 1.27% 8309M 33.8% 9.9G 35.5% - -
... 0.00 0.00% 6225M 25.3% 12.1G 43.2% 432 0.00%
$ prstat -c -p 3832 1 1
Please wait...
PID USERNAME SIZE RSS ...
3832 ... 12G 6146M ...
...
$ pmap -x 3832 | head
3832: ./shm_v04
Address Kbytes RSS ... Locked Mode Mapped File
0000000000400000 8 8 ... - r-x-- shm_v04
0000000000411000 8 8 ... - rw--- shm_v04
0000000000413000 160 68 ... - rw--- [ heap ]
FFFF80FC80000000 12582912 6291456 ... - rwxs- [ dism ... ]
...
Detaching shared memory.
Press
Success!
vlab-3 $ swap -lh; swap -sh
swapfile dev swaplo blocks free
/dev/swap - 4K 4.0G 3.9G
total: 6.5G allocated + 6.2G reserved = 13G used, 5.9G available
$ ipcs -mA
IPC status ...
T ... KEY ... NATTCH SEGSZ CPID ... ISMATTCH PROJECT
Shared Memory:
m ... 0x1 0 12884901888 3832 ... 0 group.staff
vlab-3 $ zonestat 1 1
Collecting data for first interval...
Interval: 1, Duration: 0:00:01
SUMMARY Cpus/Online: 24/24 PhysMem: 23.9G VirtMem: 27.9G
---CPU---- --PhysMem-- --VirtMem-- --PhysNet--
ZONE USED %PART USED %USED USED %USED PBYTE %PUSE
[total] 0.29 1.22% 14.1G 59.1% 22.0G 78.8% 228 0.00%
[system] 0.29 1.22% 14.1G 58.8% 9.9G 35.5% - -
... 0.00 0.00% 81.5M 0.33% 12.1G 43.2% 228 0.00%
$ prstat -c -p 3832 1 1
Please wait...
PID USERNAME SIZE RSS ...
3832 ... 5140K 2180K ...
...
$ pmap -x 3832 | head
3832: ./shm_v04
Address Kbytes RSS ... Locked Mode Mapped File
0000000000400000 8 8 ... - r-x-- shm_v04
0000000000411000 8 8 ... - rw--- shm_v04
0000000000413000 160 68 ... - rw--- [ heap ]
FFFF80FFB8F00000 1620 1024 ... - r-x-- libCstd.so.1
...
Removing shared memory.
Press <ENTER>
Success!
$ swap -lh; swap -sh
swapfile dev swaplo blocks free
/dev/swap - 4K 4.0G 3.9G
total: 500M allocated + 171M reserved = 672M used, 18G available
$ ipcs -mA
IPC status ...
T ... KEY ... NATTCH SEGSZ CPID ... ISMATTCH PROJECT
Shared Memory:
$ zonestat 1 1
Collecting data for first interval...
Interval: 1, Duration: 0:00:01
SUMMARY Cpus/Online: 24/24 PhysMem: 23.9G VirtMem: 27.9G
---CPU---- --PhysMem-- --VirtMem-- --PhysNet--
ZONE USED %PART USED %USED USED %USED PBYTE %PUSE
[total] 0.26 1.11% 8385M 34.1% 10.0G 35.9% 228 0.00%
[system] 0.26 1.11% 8303M 33.8% 9.9G 35.5% - -
... 0.00 0.00% 81.5M 0.33% 123M 0.43% 228 0.00%
$ prstat -c -p 3832 1 1
Please wait...
PID USERNAME SIZE RSS ...
3832 ... 5140K 2180K ...
...
Exiting program.
Press
When Oracle Database fellows argues that "DISM can be dynamically resized depending on the application demand" they induce sysadmins to confusion or error.
As seen above throughout ipcs -mA on all the "output groups" the shared segment size never changes. What may change is the amount of memory the application chooses to lock, contrasting to ISM where the kernel always keep the whole segment locked.
Furthermore, they also believe that "Solaris does not allocate or reserve memory of size SGA_MAX_SIZE at instance startup". Again, for me, this is a misconception of them. I'm convinced that Oracle Database do reserve one or more large DISM segments, but that may not be apparent for a DBA, but the above output shows that Solaris does.
The behavior of ::shmget() is the same for ISM and DISM. The differences start, depending on how the segment is attached to the process. But before that no system resources are actually used, just accounted in the kernel (as a "promise" to the process which called ::shmget()).
Attaching DISM to a process, also just accounts pageable (as seen by pmap -x Mode flag) virtual memory to the process, but not yet any actual resources.
Locking a portion of (or the whole) DISM segment causes adjustments to virtual memory figures (allocated x reserved) because actual resources are allocated. Memory overhead is credited into kernel figures and the process resident size (RSS) also grows.
On the 5th "output group" we see that touching more memory than is locked (as in this sample code), causes even more pages to be allocated. In the example, we touch twice more than is currently locked, just to be more eye catching.
Unlocking DISM, reliefs the accounting of virtual memory but not necessarily frees physical memory (no pageouts) as there may not be memory pressure (as in this example).
And as with ISM, detaching shared memory, just unmaps it from the process, but not from the kernel. To free kernel resources the ::shmctl() must be issued.