From owner-freebsd-questions@freebsd.org Thu Aug 20 13:16:18 2020 Return-Path: Delivered-To: freebsd-questions@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5DE2A3BE0CA for ; Thu, 20 Aug 2020 13:16:18 +0000 (UTC) (envelope-from 4250.82.1d4c2000934ba03.1596a0f8e7b2b77fc7ba868b55c72ce2@email-od.com) Received: from mailman.nyi.freebsd.org (mailman.nyi.freebsd.org [IPv6:2610:1c1:1:606c::50:13]) by mx1.freebsd.org (Postfix) with ESMTP id 4BXQC61CXjz4RF5 for ; Thu, 20 Aug 2020 13:16:18 +0000 (UTC) (envelope-from 4250.82.1d4c2000934ba03.1596a0f8e7b2b77fc7ba868b55c72ce2@email-od.com) Received: by mailman.nyi.freebsd.org (Postfix) id 297823BDFFB; Thu, 20 Aug 2020 13:16:18 +0000 (UTC) Delivered-To: questions@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 293DC3BDFFA for ; Thu, 20 Aug 2020 13:16:18 +0000 (UTC) (envelope-from 4250.82.1d4c2000934ba03.1596a0f8e7b2b77fc7ba868b55c72ce2@email-od.com) Received: from s1-b0c6.socketlabs.email-od.com (s1-b0c6.socketlabs.email-od.com [142.0.176.198]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4BXQC50nVrz4RXy for ; Thu, 20 Aug 2020 13:16:16 +0000 (UTC) (envelope-from 4250.82.1d4c2000934ba03.1596a0f8e7b2b77fc7ba868b55c72ce2@email-od.com) DKIM-Signature: v=1; a=rsa-sha256; d=email-od.com;i=@email-od.com;s=dkim; c=relaxed/relaxed; q=dns/txt; t=1597929377; x=1600521377; h=content-transfer-encoding:content-type:mime-version:references:in-reply-to:message-id:subject:cc:to:from:date:x-thread-info; bh=eGMkVHBOKu0qcgfvywozJ+4vHyCpg/3o8U5HPz8Iaps=; b=Bf5RpAqPdobD/+EzQV7Cdr90pPL2hxGeVMr1MxGmL1fG1cAdzNNT32OvH4KThrdVgtUD1ucEe4lEy6gSw3FNyBV+wFMqBkPI0B65dx1LTzz17iCJTDFHO12S8gGFJ2bUFxKmvlzP9Cw8avgutTJ7t9veq98IBstbTA8vlWqdDyk= X-Thread-Info: NDI1MC45Mi4xZDRjMjAwMDkzNGJhMDMucXVlc3Rpb25zPWZyZWVic2Qub3Jn Received: from r3.us-east-2.aws.in.socketlabs.com (r3.us-east-2.aws.in.socketlabs.com [142.0.189.3]) by mxsg2.email-od.com with ESMTP(version=Tls12 cipher=Aes256 bits=256); Thu, 20 Aug 2020 09:16:11 -0400 Received: from smtp.lan.sohara.org (EMTPY [185.202.17.215]) by r3.us-east-2.aws.in.socketlabs.com with ESMTP(version=Tls12 cipher=Aes256 bits=256); Thu, 20 Aug 2020 09:16:10 -0400 Received: from [192.168.63.1] (helo=steve.lan.sohara.org) by smtp.lan.sohara.org with smtp (Exim 4.94 (FreeBSD)) (envelope-from ) id 1k8kQL-000Bki-0Q; Thu, 20 Aug 2020 14:16:09 +0100 Date: Thu, 20 Aug 2020 14:16:08 +0100 From: Steve O'Hara-Smith To: Odhiambo Washington Cc: questions Subject: Re: Swapping when memory is idle?? Message-Id: <20200820141608.a8bb35f9dd089d9bc190253b@sohara.org> In-Reply-To: References: X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.32; amd64-portbld-freebsd12.0) X-Clacks-Overhead: "GNU Terry Pratchett" Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 4BXQC50nVrz4RXy X-Spamd-Bar: / Authentication-Results: mx1.freebsd.org; dkim=pass header.d=email-od.com header.s=dkim header.b=Bf5RpAqP; dmarc=none; spf=pass (mx1.freebsd.org: domain of 4250.82.1d4c2000934ba03.1596a0f8e7b2b77fc7ba868b55c72ce2@email-od.com designates 142.0.176.198 as permitted sender) smtp.mailfrom=4250.82.1d4c2000934ba03.1596a0f8e7b2b77fc7ba868b55c72ce2@email-od.com X-Spamd-Result: default: False [-0.16 / 15.00]; RCVD_TLS_LAST(0.00)[]; ARC_NA(0.00)[]; R_DKIM_ALLOW(-0.20)[email-od.com:s=dkim]; MID_RHS_MATCH_FROM(0.00)[]; FROM_HAS_DN(0.00)[]; RWL_MAILSPIKE_VERYGOOD(0.00)[142.0.176.198:from]; MV_CASE(0.50)[]; R_SPF_ALLOW(-0.20)[+ip4:142.0.176.0/20]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[sohara.org]; NEURAL_HAM_MEDIUM(-0.95)[-0.950]; RCVD_COUNT_THREE(0.00)[4]; TO_MATCH_ENVRCPT_SOME(0.00)[]; TO_DN_ALL(0.00)[]; DKIM_TRACE(0.00)[email-od.com:+]; RCPT_COUNT_TWO(0.00)[2]; RCVD_IN_DNSWL_NONE(0.00)[142.0.176.198:from]; NEURAL_HAM_SHORT(-0.51)[-0.511]; FREEMAIL_TO(0.00)[gmail.com]; FORGED_SENDER(0.30)[steve@sohara.org,4250.82.1d4c2000934ba03.1596a0f8e7b2b77fc7ba868b55c72ce2@email-od.com]; MIME_TRACE(0.00)[0:+]; SUBJECT_ENDS_QUESTION(1.00)[]; ASN(0.00)[asn:7381, ipnet:142.0.176.0/22, country:US]; FROM_NEQ_ENVFROM(0.00)[steve@sohara.org,4250.82.1d4c2000934ba03.1596a0f8e7b2b77fc7ba868b55c72ce2@email-od.com]; MAILMAN_DEST(0.00)[questions] X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 Aug 2020 13:16:18 -0000 On Thu, 20 Aug 2020 10:53:27 +0300 Odhiambo Washington wrote: > I have a machine with 16GB RAM and not heavily used. > I see from `top` some things that I do not understand well. > Why would a system use swap when memory is idle? The system will push pages out to swap in response to memory pressure, trying to choose the pages least likely to be used soon. Once the memory pressure recovers there will be free memory again - and the pressure may only last a tiny amount of time. However once a page is pushed out to swap it will stay there until something tries to use it - many processes have quite a lot of memory that is only touched during initialisation and that is a prime candidate for being swapped out ... of course it tends to stay that way. This is of course a good thing because it clears memory of useless cruft so next time there's a bit of memory pressure maybe nothing has to be swapped out. -- Steve O'Hara-Smith