On Sun, May 29, 2011 at 5:24 AM, Jim Klimov <[email protected]> wrote: > And actually your comment on the Sun/Oracle blog pretty much sums it up - > why sometimes much swap should be reserved and may get used even > if in practice we hope it is hever touched. If some runaway process eats > up all VM, we still want the system to be responsive enough as to get in > and kill that process. Or let it complete in a timely fashion...
While this type of administration is sometimes necessary, generally I see this as an indication of a bad application that needs babysitting. I prefer to train Solaris to do that babysitting than performing fire drills every time an application misbehaves. You may want to look at using ulimit -d (or maybe ulimit -v) to keep individual processes from doing bad things. ulimit values are inherited by from parent to child (setting ulimit in a shell gets inherited by a process created by that shell). You can use plimit to change an existing process' ulimits or view the ulimits for running processes. If a process tries to use too much memory, it will be killed - the same thing you would do if you were to log in to take care of the bad process. If you use SMF to manage the starting and stopping, it will be automatically restarted after it is killed for consuming too much memory. In this case, you probably want to use ulimit in the start script before starting the actual process. If you have a collection of processes that you are trying to put a limit on, you can run those in a resource controlled zone. Like in the URL I give below, zone.max-swap refers to memory reservations. Setting a limit on physical memory can actually induce paging (to swap and executables - see vmstat -p) even when you have no memory shortage. > > Also with JVMs as in your example, we often see Java processes > going into swap (as a difference between RSS ans SWAP fields in > prstat or top) even long before RAM is depleted. Seems it is just > the way they are designed - I guess some libraries are preloaded > and dumped into swap, so that nominally they are referenced but > actually rarely used during process lifetime... This is a common point of confusion. See http://opensolaris.org/jive/thread.jspa?messageID=255547 > > As another example, I can speak of my recent experience reported > on zfs-discuss last month. Some ZDB walks on my broken pool > consumed well over 20Gb of VM on an 8Gb box; this is one example > where lots of fast swap was needed for a non-systematic emergency > (with all the disk thrashing even on a dedicated swap disk separate > from that pool, skimming a few hours off the days-long ZDB walk gives > it more chance to complete before some freeze or power failure). Ugh. That is indeed a time where swap is needed. > > But, thanks anyway :) > > > -- Mike Gerdts http://mgerdts.blogspot.com/ _______________________________________________ sysadmin-discuss mailing list [email protected] http://mail.opensolaris.org/mailman/listinfo/sysadmin-discuss
