How to limit swap usage in Solaris?












1














I have an Oracle Solaris 11.3 which has 128 GB of Memory (RAM) and 80 GB of Swap.



I want to limit the use of swap space (not its size just the usage).



I know in more modern linux distros like Ubuntu, Fedora, CentOs , ... there is a file under /proc/sys/vm/swappiness which you can edit and change its number from 0 to 100. 0 means less usage and 100 means more usage from swap space. But unfortunately there is no directory in /proc named as sys (either on solaris 10 and 11.3).



For now:

Where should I find /proc/sys or swappiness file? If this file does not exist on solaris How should I limit the use of swap?



PS:

At the moment my memory usage is about 30% but whenever I start a new process it allocates swap to it and does not start the process correctly.



echo "::memstat" | mdb -k result is as follows:



Page Summary                 Pages             Bytes  %Tot   
----------------- ---------------- ---------------- ----
Kernel 852964 6.5G 5%
ZFS Metadata 156226 1.1G 1%
ZFS File Data 2675261 20.4G 16%
Anon 4342304 33.1G 26%
Exec and libs 1764 13.7M 0%
Page cache 28121 219.6M 0%
Free (cachelist) 18607 145.3M 0%
Free (freelist) 8687248 66.2G 52%
Total 16777216 128G


and swap -l result is:



swapfile             dev    swaplo   blocks     free   
/dev/zvol/dsk/rpool/swap 303,1 16 8388592 8388592


and prstat -Z result is:



ZONEID    NPROC  SWAP   RSS MEMORY      TIME  CPU  ZONE
0 96 97G 33G 26% 26:29:09 0.3% global









share|improve this question
























  • Have you try to redirect TMPFS to different place to free some RAM/Swap usage?
    – Romeo Ninov
    2 days ago










  • My /tmp is about 2.0 GB and only 4% used. I'm not seeking a temporary answer because this machine is under high load.
    – Vahid F
    2 days ago










  • What is result of swap -l and echo "::memstat" | mdb -k
    – Romeo Ninov
    2 days ago










  • Edit your question, not answer. And crop the listing to the most consuming programs
    – Romeo Ninov
    2 days ago








  • 1




    Doesn't look like anything is using swap. Are you sure it's not better to let the kernel do its thing?
    – roaima
    2 days ago
















1














I have an Oracle Solaris 11.3 which has 128 GB of Memory (RAM) and 80 GB of Swap.



I want to limit the use of swap space (not its size just the usage).



I know in more modern linux distros like Ubuntu, Fedora, CentOs , ... there is a file under /proc/sys/vm/swappiness which you can edit and change its number from 0 to 100. 0 means less usage and 100 means more usage from swap space. But unfortunately there is no directory in /proc named as sys (either on solaris 10 and 11.3).



For now:

Where should I find /proc/sys or swappiness file? If this file does not exist on solaris How should I limit the use of swap?



PS:

At the moment my memory usage is about 30% but whenever I start a new process it allocates swap to it and does not start the process correctly.



echo "::memstat" | mdb -k result is as follows:



Page Summary                 Pages             Bytes  %Tot   
----------------- ---------------- ---------------- ----
Kernel 852964 6.5G 5%
ZFS Metadata 156226 1.1G 1%
ZFS File Data 2675261 20.4G 16%
Anon 4342304 33.1G 26%
Exec and libs 1764 13.7M 0%
Page cache 28121 219.6M 0%
Free (cachelist) 18607 145.3M 0%
Free (freelist) 8687248 66.2G 52%
Total 16777216 128G


and swap -l result is:



swapfile             dev    swaplo   blocks     free   
/dev/zvol/dsk/rpool/swap 303,1 16 8388592 8388592


and prstat -Z result is:



ZONEID    NPROC  SWAP   RSS MEMORY      TIME  CPU  ZONE
0 96 97G 33G 26% 26:29:09 0.3% global









share|improve this question
























  • Have you try to redirect TMPFS to different place to free some RAM/Swap usage?
    – Romeo Ninov
    2 days ago










  • My /tmp is about 2.0 GB and only 4% used. I'm not seeking a temporary answer because this machine is under high load.
    – Vahid F
    2 days ago










  • What is result of swap -l and echo "::memstat" | mdb -k
    – Romeo Ninov
    2 days ago










  • Edit your question, not answer. And crop the listing to the most consuming programs
    – Romeo Ninov
    2 days ago








  • 1




    Doesn't look like anything is using swap. Are you sure it's not better to let the kernel do its thing?
    – roaima
    2 days ago














1












1








1







I have an Oracle Solaris 11.3 which has 128 GB of Memory (RAM) and 80 GB of Swap.



I want to limit the use of swap space (not its size just the usage).



I know in more modern linux distros like Ubuntu, Fedora, CentOs , ... there is a file under /proc/sys/vm/swappiness which you can edit and change its number from 0 to 100. 0 means less usage and 100 means more usage from swap space. But unfortunately there is no directory in /proc named as sys (either on solaris 10 and 11.3).



For now:

Where should I find /proc/sys or swappiness file? If this file does not exist on solaris How should I limit the use of swap?



PS:

At the moment my memory usage is about 30% but whenever I start a new process it allocates swap to it and does not start the process correctly.



echo "::memstat" | mdb -k result is as follows:



Page Summary                 Pages             Bytes  %Tot   
----------------- ---------------- ---------------- ----
Kernel 852964 6.5G 5%
ZFS Metadata 156226 1.1G 1%
ZFS File Data 2675261 20.4G 16%
Anon 4342304 33.1G 26%
Exec and libs 1764 13.7M 0%
Page cache 28121 219.6M 0%
Free (cachelist) 18607 145.3M 0%
Free (freelist) 8687248 66.2G 52%
Total 16777216 128G


and swap -l result is:



swapfile             dev    swaplo   blocks     free   
/dev/zvol/dsk/rpool/swap 303,1 16 8388592 8388592


and prstat -Z result is:



ZONEID    NPROC  SWAP   RSS MEMORY      TIME  CPU  ZONE
0 96 97G 33G 26% 26:29:09 0.3% global









share|improve this question















I have an Oracle Solaris 11.3 which has 128 GB of Memory (RAM) and 80 GB of Swap.



I want to limit the use of swap space (not its size just the usage).



I know in more modern linux distros like Ubuntu, Fedora, CentOs , ... there is a file under /proc/sys/vm/swappiness which you can edit and change its number from 0 to 100. 0 means less usage and 100 means more usage from swap space. But unfortunately there is no directory in /proc named as sys (either on solaris 10 and 11.3).



For now:

Where should I find /proc/sys or swappiness file? If this file does not exist on solaris How should I limit the use of swap?



PS:

At the moment my memory usage is about 30% but whenever I start a new process it allocates swap to it and does not start the process correctly.



echo "::memstat" | mdb -k result is as follows:



Page Summary                 Pages             Bytes  %Tot   
----------------- ---------------- ---------------- ----
Kernel 852964 6.5G 5%
ZFS Metadata 156226 1.1G 1%
ZFS File Data 2675261 20.4G 16%
Anon 4342304 33.1G 26%
Exec and libs 1764 13.7M 0%
Page cache 28121 219.6M 0%
Free (cachelist) 18607 145.3M 0%
Free (freelist) 8687248 66.2G 52%
Total 16777216 128G


and swap -l result is:



swapfile             dev    swaplo   blocks     free   
/dev/zvol/dsk/rpool/swap 303,1 16 8388592 8388592


and prstat -Z result is:



ZONEID    NPROC  SWAP   RSS MEMORY      TIME  CPU  ZONE
0 96 97G 33G 26% 26:29:09 0.3% global






solaris swap out-of-memory






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited yesterday

























asked 2 days ago









Vahid F

83




83












  • Have you try to redirect TMPFS to different place to free some RAM/Swap usage?
    – Romeo Ninov
    2 days ago










  • My /tmp is about 2.0 GB and only 4% used. I'm not seeking a temporary answer because this machine is under high load.
    – Vahid F
    2 days ago










  • What is result of swap -l and echo "::memstat" | mdb -k
    – Romeo Ninov
    2 days ago










  • Edit your question, not answer. And crop the listing to the most consuming programs
    – Romeo Ninov
    2 days ago








  • 1




    Doesn't look like anything is using swap. Are you sure it's not better to let the kernel do its thing?
    – roaima
    2 days ago


















  • Have you try to redirect TMPFS to different place to free some RAM/Swap usage?
    – Romeo Ninov
    2 days ago










  • My /tmp is about 2.0 GB and only 4% used. I'm not seeking a temporary answer because this machine is under high load.
    – Vahid F
    2 days ago










  • What is result of swap -l and echo "::memstat" | mdb -k
    – Romeo Ninov
    2 days ago










  • Edit your question, not answer. And crop the listing to the most consuming programs
    – Romeo Ninov
    2 days ago








  • 1




    Doesn't look like anything is using swap. Are you sure it's not better to let the kernel do its thing?
    – roaima
    2 days ago
















Have you try to redirect TMPFS to different place to free some RAM/Swap usage?
– Romeo Ninov
2 days ago




Have you try to redirect TMPFS to different place to free some RAM/Swap usage?
– Romeo Ninov
2 days ago












My /tmp is about 2.0 GB and only 4% used. I'm not seeking a temporary answer because this machine is under high load.
– Vahid F
2 days ago




My /tmp is about 2.0 GB and only 4% used. I'm not seeking a temporary answer because this machine is under high load.
– Vahid F
2 days ago












What is result of swap -l and echo "::memstat" | mdb -k
– Romeo Ninov
2 days ago




What is result of swap -l and echo "::memstat" | mdb -k
– Romeo Ninov
2 days ago












Edit your question, not answer. And crop the listing to the most consuming programs
– Romeo Ninov
2 days ago






Edit your question, not answer. And crop the listing to the most consuming programs
– Romeo Ninov
2 days ago






1




1




Doesn't look like anything is using swap. Are you sure it's not better to let the kernel do its thing?
– roaima
2 days ago




Doesn't look like anything is using swap. Are you sure it's not better to let the kernel do its thing?
– roaima
2 days ago










1 Answer
1






active

oldest

votes


















3















I want to limit the use of swap space (not its size just the usage).




You can not limit swap reservations in Solaris.



Just about every byte of RAM used by a process is guaranteed by Solaris to have some sort of persistent backing store available. (There are some exceptions to that on Solaris, such as some types of shared memory, which do not need swap reservations because they can't be swapped out. Implementations like Oracle database SGAs use these features.)



Memory-maped files, such as executables and shared objects, usually use the actual file on disk as the backing store, and thus don't use swap space at all. Most other memory usages need a backing store. For example, if a process asks the kernel for a 2 GB heap but never actually uses it, that will cause a 2 GB reservation against swap space, because Solaris guarantees that if a process asks for memory, it will get it. There's no OOM killer that kills your database process on your production database server or your web server on your online web server processing customer orders...



On Solaris, if you ask for memory and the kernel says you can have it, you get it. Even if you don't actually use it until after a long, long period of time. That means if you ask for it, the kernel has to make sure there's a place to put it if it has to be swapped out in the future for any reason.



There's a cost to running under a "I said you can have this memory, and that means you WILL be able to access it no matter what" paradigm instead of a "I said you can have this memory but I lied to you and now that you've tried to use it I'm going to kill you" paradigm, and that cost is what might seem like exorbitant swap usage.



To see the swap usage of a process, you can use the pmap -S command:



bash-4.1$ pmap -S $$
4622: /usr/bin/bash
Address Kbytes Swap Mode Mapped File
0000000000400000 1412 - r-x---- bash
0000000000571000 40 40 rw----- bash
000000000057B000 24 24 rw----- bash
0000000EC09E6000 236 236 rw----- [ heap ]
00007FF0C8590000 304 - r-x---- libcurses.so.1
00007FF0C85EC000 20 20 rw----- libcurses.so.1
00007FF0C85F1000 16 16 rw----- libcurses.so.1
00007FF0C8600000 6756 - r-x---- en_US.UTF-8.so.3
00007FF0C8CA9000 8 8 rw----- en_US.UTF-8.so.3
00007FF0C8CD0000 32 - r-x---- libgen.so.1
00007FF0C8CE8000 4 4 rw----- libgen.so.1
00007FF0C8CF0000 64 64 rwx---- [ anon ]
00007FF0C8D10000 64 64 rwx---- [ anon ]
00007FF0C8D2D000 4 - rwxs--- [ anon ]
00007FF0C8D30000 64 - r-x---- methods_unicode.so.3
00007FF0C8D40000 4 4 rw----- methods_unicode.so.3
00007FF0C8D50000 24 24 rwx---- [ anon ]
00007FF0C8D60000 1816 - r-x---- libc.so.1
00007FF0C8F36000 68 68 rw----- libc.so.1
00007FF0C8F47000 8 8 rw----- libc.so.1
00007FF0C8F50000 64 64 rw----- [ anon ]
00007FF0C8F6C000 352 - r-x---- ld.so.1
00007FF0C8FD4000 16 16 rwx---- ld.so.1
00007FF0C8FD8000 4 4 rwx---- ld.so.1
FFFF80E6271AF000 20 20 rw----- [ stack ]
---------------- ---------- ----------
total Kb 11424 684


Note this line:



0000000000400000       1412          - r-x----  bash


The Swap column indicates that particular memory mapping requires no swap usage at all. That's the part of the bash executable that's backed by the on-disk /usr/bin/bash file itself.



But this line:



0000000000571000         40         40 rw-----  bash


uses 40 kb of swap. It's likely a data segment mapped from /usr/bin/bash, but since it's modifiable data (note the rw permissions), the backing store can't be the non-modifiable /usr/bin/bash disk file, so it gets a 40 kb swap reservation.



Note that all of the heap, anon, and stack mappings are backed by swap space in their entirety.



Bottom line:



On Solaris, if you don't want to use up all your swap space to the point where you can't start new processes, don't have your processes ask for memory they don't actually use.



Or make a bigger swap partition.






share|improve this answer





















  • Dear andrew please take a look at this article: docs.oracle.com/cd/E24290_01/coh.371/e22838/… If you are right so why oracle has introduced this article in its tuning section?
    – Vahid F
    23 hours ago












  • @VahidF The Linux tuning of "swappiness" has nothing to do with swap reservations on either Linux or Solaris. You can't "tune" swap reservations - if your process asks for a 16 GB heap, that requires a 16 GB swap reservation. On Linux you get away with not having enough swap space to ensure all memory has a proper backing store because by default Linux does memory overcommit - Linux LIES to you about whether or not you can REALLY use all that memory. Solaris doesn't lie about that - if you ask for it, you WILL get it. Which means if there isn't enough swap, your process fails.
    – Andrew Henle
    20 hours ago










  • @VahidF Again, you have two solutions for this: 1. Stop having your processes ask for huge amounts of memory that they don't actually use 2. Add more space to your swap partition(s). Period. Full stop. That's it. You can't tune your way out of that.
    – Andrew Henle
    20 hours ago










  • Is there any way to add swap space on solaris without reinstalling OS?
    – Vahid F
    20 hours ago










  • @VahidF This describes one way: docs.oracle.com/cd/E53394_01/html/E54801/ggvlr.html Reading the swap man page (via man swap) should also help.
    – Andrew Henle
    19 hours ago











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f492624%2fhow-to-limit-swap-usage-in-solaris%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









3















I want to limit the use of swap space (not its size just the usage).




You can not limit swap reservations in Solaris.



Just about every byte of RAM used by a process is guaranteed by Solaris to have some sort of persistent backing store available. (There are some exceptions to that on Solaris, such as some types of shared memory, which do not need swap reservations because they can't be swapped out. Implementations like Oracle database SGAs use these features.)



Memory-maped files, such as executables and shared objects, usually use the actual file on disk as the backing store, and thus don't use swap space at all. Most other memory usages need a backing store. For example, if a process asks the kernel for a 2 GB heap but never actually uses it, that will cause a 2 GB reservation against swap space, because Solaris guarantees that if a process asks for memory, it will get it. There's no OOM killer that kills your database process on your production database server or your web server on your online web server processing customer orders...



On Solaris, if you ask for memory and the kernel says you can have it, you get it. Even if you don't actually use it until after a long, long period of time. That means if you ask for it, the kernel has to make sure there's a place to put it if it has to be swapped out in the future for any reason.



There's a cost to running under a "I said you can have this memory, and that means you WILL be able to access it no matter what" paradigm instead of a "I said you can have this memory but I lied to you and now that you've tried to use it I'm going to kill you" paradigm, and that cost is what might seem like exorbitant swap usage.



To see the swap usage of a process, you can use the pmap -S command:



bash-4.1$ pmap -S $$
4622: /usr/bin/bash
Address Kbytes Swap Mode Mapped File
0000000000400000 1412 - r-x---- bash
0000000000571000 40 40 rw----- bash
000000000057B000 24 24 rw----- bash
0000000EC09E6000 236 236 rw----- [ heap ]
00007FF0C8590000 304 - r-x---- libcurses.so.1
00007FF0C85EC000 20 20 rw----- libcurses.so.1
00007FF0C85F1000 16 16 rw----- libcurses.so.1
00007FF0C8600000 6756 - r-x---- en_US.UTF-8.so.3
00007FF0C8CA9000 8 8 rw----- en_US.UTF-8.so.3
00007FF0C8CD0000 32 - r-x---- libgen.so.1
00007FF0C8CE8000 4 4 rw----- libgen.so.1
00007FF0C8CF0000 64 64 rwx---- [ anon ]
00007FF0C8D10000 64 64 rwx---- [ anon ]
00007FF0C8D2D000 4 - rwxs--- [ anon ]
00007FF0C8D30000 64 - r-x---- methods_unicode.so.3
00007FF0C8D40000 4 4 rw----- methods_unicode.so.3
00007FF0C8D50000 24 24 rwx---- [ anon ]
00007FF0C8D60000 1816 - r-x---- libc.so.1
00007FF0C8F36000 68 68 rw----- libc.so.1
00007FF0C8F47000 8 8 rw----- libc.so.1
00007FF0C8F50000 64 64 rw----- [ anon ]
00007FF0C8F6C000 352 - r-x---- ld.so.1
00007FF0C8FD4000 16 16 rwx---- ld.so.1
00007FF0C8FD8000 4 4 rwx---- ld.so.1
FFFF80E6271AF000 20 20 rw----- [ stack ]
---------------- ---------- ----------
total Kb 11424 684


Note this line:



0000000000400000       1412          - r-x----  bash


The Swap column indicates that particular memory mapping requires no swap usage at all. That's the part of the bash executable that's backed by the on-disk /usr/bin/bash file itself.



But this line:



0000000000571000         40         40 rw-----  bash


uses 40 kb of swap. It's likely a data segment mapped from /usr/bin/bash, but since it's modifiable data (note the rw permissions), the backing store can't be the non-modifiable /usr/bin/bash disk file, so it gets a 40 kb swap reservation.



Note that all of the heap, anon, and stack mappings are backed by swap space in their entirety.



Bottom line:



On Solaris, if you don't want to use up all your swap space to the point where you can't start new processes, don't have your processes ask for memory they don't actually use.



Or make a bigger swap partition.






share|improve this answer





















  • Dear andrew please take a look at this article: docs.oracle.com/cd/E24290_01/coh.371/e22838/… If you are right so why oracle has introduced this article in its tuning section?
    – Vahid F
    23 hours ago












  • @VahidF The Linux tuning of "swappiness" has nothing to do with swap reservations on either Linux or Solaris. You can't "tune" swap reservations - if your process asks for a 16 GB heap, that requires a 16 GB swap reservation. On Linux you get away with not having enough swap space to ensure all memory has a proper backing store because by default Linux does memory overcommit - Linux LIES to you about whether or not you can REALLY use all that memory. Solaris doesn't lie about that - if you ask for it, you WILL get it. Which means if there isn't enough swap, your process fails.
    – Andrew Henle
    20 hours ago










  • @VahidF Again, you have two solutions for this: 1. Stop having your processes ask for huge amounts of memory that they don't actually use 2. Add more space to your swap partition(s). Period. Full stop. That's it. You can't tune your way out of that.
    – Andrew Henle
    20 hours ago










  • Is there any way to add swap space on solaris without reinstalling OS?
    – Vahid F
    20 hours ago










  • @VahidF This describes one way: docs.oracle.com/cd/E53394_01/html/E54801/ggvlr.html Reading the swap man page (via man swap) should also help.
    – Andrew Henle
    19 hours ago
















3















I want to limit the use of swap space (not its size just the usage).




You can not limit swap reservations in Solaris.



Just about every byte of RAM used by a process is guaranteed by Solaris to have some sort of persistent backing store available. (There are some exceptions to that on Solaris, such as some types of shared memory, which do not need swap reservations because they can't be swapped out. Implementations like Oracle database SGAs use these features.)



Memory-maped files, such as executables and shared objects, usually use the actual file on disk as the backing store, and thus don't use swap space at all. Most other memory usages need a backing store. For example, if a process asks the kernel for a 2 GB heap but never actually uses it, that will cause a 2 GB reservation against swap space, because Solaris guarantees that if a process asks for memory, it will get it. There's no OOM killer that kills your database process on your production database server or your web server on your online web server processing customer orders...



On Solaris, if you ask for memory and the kernel says you can have it, you get it. Even if you don't actually use it until after a long, long period of time. That means if you ask for it, the kernel has to make sure there's a place to put it if it has to be swapped out in the future for any reason.



There's a cost to running under a "I said you can have this memory, and that means you WILL be able to access it no matter what" paradigm instead of a "I said you can have this memory but I lied to you and now that you've tried to use it I'm going to kill you" paradigm, and that cost is what might seem like exorbitant swap usage.



To see the swap usage of a process, you can use the pmap -S command:



bash-4.1$ pmap -S $$
4622: /usr/bin/bash
Address Kbytes Swap Mode Mapped File
0000000000400000 1412 - r-x---- bash
0000000000571000 40 40 rw----- bash
000000000057B000 24 24 rw----- bash
0000000EC09E6000 236 236 rw----- [ heap ]
00007FF0C8590000 304 - r-x---- libcurses.so.1
00007FF0C85EC000 20 20 rw----- libcurses.so.1
00007FF0C85F1000 16 16 rw----- libcurses.so.1
00007FF0C8600000 6756 - r-x---- en_US.UTF-8.so.3
00007FF0C8CA9000 8 8 rw----- en_US.UTF-8.so.3
00007FF0C8CD0000 32 - r-x---- libgen.so.1
00007FF0C8CE8000 4 4 rw----- libgen.so.1
00007FF0C8CF0000 64 64 rwx---- [ anon ]
00007FF0C8D10000 64 64 rwx---- [ anon ]
00007FF0C8D2D000 4 - rwxs--- [ anon ]
00007FF0C8D30000 64 - r-x---- methods_unicode.so.3
00007FF0C8D40000 4 4 rw----- methods_unicode.so.3
00007FF0C8D50000 24 24 rwx---- [ anon ]
00007FF0C8D60000 1816 - r-x---- libc.so.1
00007FF0C8F36000 68 68 rw----- libc.so.1
00007FF0C8F47000 8 8 rw----- libc.so.1
00007FF0C8F50000 64 64 rw----- [ anon ]
00007FF0C8F6C000 352 - r-x---- ld.so.1
00007FF0C8FD4000 16 16 rwx---- ld.so.1
00007FF0C8FD8000 4 4 rwx---- ld.so.1
FFFF80E6271AF000 20 20 rw----- [ stack ]
---------------- ---------- ----------
total Kb 11424 684


Note this line:



0000000000400000       1412          - r-x----  bash


The Swap column indicates that particular memory mapping requires no swap usage at all. That's the part of the bash executable that's backed by the on-disk /usr/bin/bash file itself.



But this line:



0000000000571000         40         40 rw-----  bash


uses 40 kb of swap. It's likely a data segment mapped from /usr/bin/bash, but since it's modifiable data (note the rw permissions), the backing store can't be the non-modifiable /usr/bin/bash disk file, so it gets a 40 kb swap reservation.



Note that all of the heap, anon, and stack mappings are backed by swap space in their entirety.



Bottom line:



On Solaris, if you don't want to use up all your swap space to the point where you can't start new processes, don't have your processes ask for memory they don't actually use.



Or make a bigger swap partition.






share|improve this answer





















  • Dear andrew please take a look at this article: docs.oracle.com/cd/E24290_01/coh.371/e22838/… If you are right so why oracle has introduced this article in its tuning section?
    – Vahid F
    23 hours ago












  • @VahidF The Linux tuning of "swappiness" has nothing to do with swap reservations on either Linux or Solaris. You can't "tune" swap reservations - if your process asks for a 16 GB heap, that requires a 16 GB swap reservation. On Linux you get away with not having enough swap space to ensure all memory has a proper backing store because by default Linux does memory overcommit - Linux LIES to you about whether or not you can REALLY use all that memory. Solaris doesn't lie about that - if you ask for it, you WILL get it. Which means if there isn't enough swap, your process fails.
    – Andrew Henle
    20 hours ago










  • @VahidF Again, you have two solutions for this: 1. Stop having your processes ask for huge amounts of memory that they don't actually use 2. Add more space to your swap partition(s). Period. Full stop. That's it. You can't tune your way out of that.
    – Andrew Henle
    20 hours ago










  • Is there any way to add swap space on solaris without reinstalling OS?
    – Vahid F
    20 hours ago










  • @VahidF This describes one way: docs.oracle.com/cd/E53394_01/html/E54801/ggvlr.html Reading the swap man page (via man swap) should also help.
    – Andrew Henle
    19 hours ago














3












3








3







I want to limit the use of swap space (not its size just the usage).




You can not limit swap reservations in Solaris.



Just about every byte of RAM used by a process is guaranteed by Solaris to have some sort of persistent backing store available. (There are some exceptions to that on Solaris, such as some types of shared memory, which do not need swap reservations because they can't be swapped out. Implementations like Oracle database SGAs use these features.)



Memory-maped files, such as executables and shared objects, usually use the actual file on disk as the backing store, and thus don't use swap space at all. Most other memory usages need a backing store. For example, if a process asks the kernel for a 2 GB heap but never actually uses it, that will cause a 2 GB reservation against swap space, because Solaris guarantees that if a process asks for memory, it will get it. There's no OOM killer that kills your database process on your production database server or your web server on your online web server processing customer orders...



On Solaris, if you ask for memory and the kernel says you can have it, you get it. Even if you don't actually use it until after a long, long period of time. That means if you ask for it, the kernel has to make sure there's a place to put it if it has to be swapped out in the future for any reason.



There's a cost to running under a "I said you can have this memory, and that means you WILL be able to access it no matter what" paradigm instead of a "I said you can have this memory but I lied to you and now that you've tried to use it I'm going to kill you" paradigm, and that cost is what might seem like exorbitant swap usage.



To see the swap usage of a process, you can use the pmap -S command:



bash-4.1$ pmap -S $$
4622: /usr/bin/bash
Address Kbytes Swap Mode Mapped File
0000000000400000 1412 - r-x---- bash
0000000000571000 40 40 rw----- bash
000000000057B000 24 24 rw----- bash
0000000EC09E6000 236 236 rw----- [ heap ]
00007FF0C8590000 304 - r-x---- libcurses.so.1
00007FF0C85EC000 20 20 rw----- libcurses.so.1
00007FF0C85F1000 16 16 rw----- libcurses.so.1
00007FF0C8600000 6756 - r-x---- en_US.UTF-8.so.3
00007FF0C8CA9000 8 8 rw----- en_US.UTF-8.so.3
00007FF0C8CD0000 32 - r-x---- libgen.so.1
00007FF0C8CE8000 4 4 rw----- libgen.so.1
00007FF0C8CF0000 64 64 rwx---- [ anon ]
00007FF0C8D10000 64 64 rwx---- [ anon ]
00007FF0C8D2D000 4 - rwxs--- [ anon ]
00007FF0C8D30000 64 - r-x---- methods_unicode.so.3
00007FF0C8D40000 4 4 rw----- methods_unicode.so.3
00007FF0C8D50000 24 24 rwx---- [ anon ]
00007FF0C8D60000 1816 - r-x---- libc.so.1
00007FF0C8F36000 68 68 rw----- libc.so.1
00007FF0C8F47000 8 8 rw----- libc.so.1
00007FF0C8F50000 64 64 rw----- [ anon ]
00007FF0C8F6C000 352 - r-x---- ld.so.1
00007FF0C8FD4000 16 16 rwx---- ld.so.1
00007FF0C8FD8000 4 4 rwx---- ld.so.1
FFFF80E6271AF000 20 20 rw----- [ stack ]
---------------- ---------- ----------
total Kb 11424 684


Note this line:



0000000000400000       1412          - r-x----  bash


The Swap column indicates that particular memory mapping requires no swap usage at all. That's the part of the bash executable that's backed by the on-disk /usr/bin/bash file itself.



But this line:



0000000000571000         40         40 rw-----  bash


uses 40 kb of swap. It's likely a data segment mapped from /usr/bin/bash, but since it's modifiable data (note the rw permissions), the backing store can't be the non-modifiable /usr/bin/bash disk file, so it gets a 40 kb swap reservation.



Note that all of the heap, anon, and stack mappings are backed by swap space in their entirety.



Bottom line:



On Solaris, if you don't want to use up all your swap space to the point where you can't start new processes, don't have your processes ask for memory they don't actually use.



Or make a bigger swap partition.






share|improve this answer













I want to limit the use of swap space (not its size just the usage).




You can not limit swap reservations in Solaris.



Just about every byte of RAM used by a process is guaranteed by Solaris to have some sort of persistent backing store available. (There are some exceptions to that on Solaris, such as some types of shared memory, which do not need swap reservations because they can't be swapped out. Implementations like Oracle database SGAs use these features.)



Memory-maped files, such as executables and shared objects, usually use the actual file on disk as the backing store, and thus don't use swap space at all. Most other memory usages need a backing store. For example, if a process asks the kernel for a 2 GB heap but never actually uses it, that will cause a 2 GB reservation against swap space, because Solaris guarantees that if a process asks for memory, it will get it. There's no OOM killer that kills your database process on your production database server or your web server on your online web server processing customer orders...



On Solaris, if you ask for memory and the kernel says you can have it, you get it. Even if you don't actually use it until after a long, long period of time. That means if you ask for it, the kernel has to make sure there's a place to put it if it has to be swapped out in the future for any reason.



There's a cost to running under a "I said you can have this memory, and that means you WILL be able to access it no matter what" paradigm instead of a "I said you can have this memory but I lied to you and now that you've tried to use it I'm going to kill you" paradigm, and that cost is what might seem like exorbitant swap usage.



To see the swap usage of a process, you can use the pmap -S command:



bash-4.1$ pmap -S $$
4622: /usr/bin/bash
Address Kbytes Swap Mode Mapped File
0000000000400000 1412 - r-x---- bash
0000000000571000 40 40 rw----- bash
000000000057B000 24 24 rw----- bash
0000000EC09E6000 236 236 rw----- [ heap ]
00007FF0C8590000 304 - r-x---- libcurses.so.1
00007FF0C85EC000 20 20 rw----- libcurses.so.1
00007FF0C85F1000 16 16 rw----- libcurses.so.1
00007FF0C8600000 6756 - r-x---- en_US.UTF-8.so.3
00007FF0C8CA9000 8 8 rw----- en_US.UTF-8.so.3
00007FF0C8CD0000 32 - r-x---- libgen.so.1
00007FF0C8CE8000 4 4 rw----- libgen.so.1
00007FF0C8CF0000 64 64 rwx---- [ anon ]
00007FF0C8D10000 64 64 rwx---- [ anon ]
00007FF0C8D2D000 4 - rwxs--- [ anon ]
00007FF0C8D30000 64 - r-x---- methods_unicode.so.3
00007FF0C8D40000 4 4 rw----- methods_unicode.so.3
00007FF0C8D50000 24 24 rwx---- [ anon ]
00007FF0C8D60000 1816 - r-x---- libc.so.1
00007FF0C8F36000 68 68 rw----- libc.so.1
00007FF0C8F47000 8 8 rw----- libc.so.1
00007FF0C8F50000 64 64 rw----- [ anon ]
00007FF0C8F6C000 352 - r-x---- ld.so.1
00007FF0C8FD4000 16 16 rwx---- ld.so.1
00007FF0C8FD8000 4 4 rwx---- ld.so.1
FFFF80E6271AF000 20 20 rw----- [ stack ]
---------------- ---------- ----------
total Kb 11424 684


Note this line:



0000000000400000       1412          - r-x----  bash


The Swap column indicates that particular memory mapping requires no swap usage at all. That's the part of the bash executable that's backed by the on-disk /usr/bin/bash file itself.



But this line:



0000000000571000         40         40 rw-----  bash


uses 40 kb of swap. It's likely a data segment mapped from /usr/bin/bash, but since it's modifiable data (note the rw permissions), the backing store can't be the non-modifiable /usr/bin/bash disk file, so it gets a 40 kb swap reservation.



Note that all of the heap, anon, and stack mappings are backed by swap space in their entirety.



Bottom line:



On Solaris, if you don't want to use up all your swap space to the point where you can't start new processes, don't have your processes ask for memory they don't actually use.



Or make a bigger swap partition.







share|improve this answer












share|improve this answer



share|improve this answer










answered yesterday









Andrew Henle

2,677911




2,677911












  • Dear andrew please take a look at this article: docs.oracle.com/cd/E24290_01/coh.371/e22838/… If you are right so why oracle has introduced this article in its tuning section?
    – Vahid F
    23 hours ago












  • @VahidF The Linux tuning of "swappiness" has nothing to do with swap reservations on either Linux or Solaris. You can't "tune" swap reservations - if your process asks for a 16 GB heap, that requires a 16 GB swap reservation. On Linux you get away with not having enough swap space to ensure all memory has a proper backing store because by default Linux does memory overcommit - Linux LIES to you about whether or not you can REALLY use all that memory. Solaris doesn't lie about that - if you ask for it, you WILL get it. Which means if there isn't enough swap, your process fails.
    – Andrew Henle
    20 hours ago










  • @VahidF Again, you have two solutions for this: 1. Stop having your processes ask for huge amounts of memory that they don't actually use 2. Add more space to your swap partition(s). Period. Full stop. That's it. You can't tune your way out of that.
    – Andrew Henle
    20 hours ago










  • Is there any way to add swap space on solaris without reinstalling OS?
    – Vahid F
    20 hours ago










  • @VahidF This describes one way: docs.oracle.com/cd/E53394_01/html/E54801/ggvlr.html Reading the swap man page (via man swap) should also help.
    – Andrew Henle
    19 hours ago


















  • Dear andrew please take a look at this article: docs.oracle.com/cd/E24290_01/coh.371/e22838/… If you are right so why oracle has introduced this article in its tuning section?
    – Vahid F
    23 hours ago












  • @VahidF The Linux tuning of "swappiness" has nothing to do with swap reservations on either Linux or Solaris. You can't "tune" swap reservations - if your process asks for a 16 GB heap, that requires a 16 GB swap reservation. On Linux you get away with not having enough swap space to ensure all memory has a proper backing store because by default Linux does memory overcommit - Linux LIES to you about whether or not you can REALLY use all that memory. Solaris doesn't lie about that - if you ask for it, you WILL get it. Which means if there isn't enough swap, your process fails.
    – Andrew Henle
    20 hours ago










  • @VahidF Again, you have two solutions for this: 1. Stop having your processes ask for huge amounts of memory that they don't actually use 2. Add more space to your swap partition(s). Period. Full stop. That's it. You can't tune your way out of that.
    – Andrew Henle
    20 hours ago










  • Is there any way to add swap space on solaris without reinstalling OS?
    – Vahid F
    20 hours ago










  • @VahidF This describes one way: docs.oracle.com/cd/E53394_01/html/E54801/ggvlr.html Reading the swap man page (via man swap) should also help.
    – Andrew Henle
    19 hours ago
















Dear andrew please take a look at this article: docs.oracle.com/cd/E24290_01/coh.371/e22838/… If you are right so why oracle has introduced this article in its tuning section?
– Vahid F
23 hours ago






Dear andrew please take a look at this article: docs.oracle.com/cd/E24290_01/coh.371/e22838/… If you are right so why oracle has introduced this article in its tuning section?
– Vahid F
23 hours ago














@VahidF The Linux tuning of "swappiness" has nothing to do with swap reservations on either Linux or Solaris. You can't "tune" swap reservations - if your process asks for a 16 GB heap, that requires a 16 GB swap reservation. On Linux you get away with not having enough swap space to ensure all memory has a proper backing store because by default Linux does memory overcommit - Linux LIES to you about whether or not you can REALLY use all that memory. Solaris doesn't lie about that - if you ask for it, you WILL get it. Which means if there isn't enough swap, your process fails.
– Andrew Henle
20 hours ago




@VahidF The Linux tuning of "swappiness" has nothing to do with swap reservations on either Linux or Solaris. You can't "tune" swap reservations - if your process asks for a 16 GB heap, that requires a 16 GB swap reservation. On Linux you get away with not having enough swap space to ensure all memory has a proper backing store because by default Linux does memory overcommit - Linux LIES to you about whether or not you can REALLY use all that memory. Solaris doesn't lie about that - if you ask for it, you WILL get it. Which means if there isn't enough swap, your process fails.
– Andrew Henle
20 hours ago












@VahidF Again, you have two solutions for this: 1. Stop having your processes ask for huge amounts of memory that they don't actually use 2. Add more space to your swap partition(s). Period. Full stop. That's it. You can't tune your way out of that.
– Andrew Henle
20 hours ago




@VahidF Again, you have two solutions for this: 1. Stop having your processes ask for huge amounts of memory that they don't actually use 2. Add more space to your swap partition(s). Period. Full stop. That's it. You can't tune your way out of that.
– Andrew Henle
20 hours ago












Is there any way to add swap space on solaris without reinstalling OS?
– Vahid F
20 hours ago




Is there any way to add swap space on solaris without reinstalling OS?
– Vahid F
20 hours ago












@VahidF This describes one way: docs.oracle.com/cd/E53394_01/html/E54801/ggvlr.html Reading the swap man page (via man swap) should also help.
– Andrew Henle
19 hours ago




@VahidF This describes one way: docs.oracle.com/cd/E53394_01/html/E54801/ggvlr.html Reading the swap man page (via man swap) should also help.
– Andrew Henle
19 hours ago


















draft saved

draft discarded




















































Thanks for contributing an answer to Unix & Linux Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f492624%2fhow-to-limit-swap-usage-in-solaris%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

How to reconfigure Docker Trusted Registry 2.x.x to use CEPH FS mount instead of NFS and other traditional...

is 'sed' thread safe

How to make a Squid Proxy server?