TIP: Click on subject to list as thread! ANSI
echo: rberrypi
to: GREGORIE
from: JAN PANTELTJE
date: 2020-01-24 12:59:00
subject: Re: Question about ever g

On a sunny day (Fri, 24 Jan 2020 11:39:33 -0000 (UTC)) it happened Martin
Gregorie  wrote in :

>On Fri, 24 Jan 2020 08:55:25 +0000, The Natural Philosopher wrote:
>
>> On 24/01/2020 08:18, Andy Burns wrote:
>>> Jan Panteltje wrote:
>>>
>>>> top shows:
>>>>
>>>> MiB Mem :   3906.0 total,     71.6 free,    375.9 used,  
3458.6
>>>> buff/cache MiB Swap:    100.0 total,     19.9 free,     80.1
used.  
>>>> 3364.1 avail Mem
>>>>
>>>> kernel claims all memory space as cache
>>>
>>> You have that backwards.
>>>
>>>  From your 3906 MB, 375 MB is used, the kernel is keeping 71 MB free
>>>  for
>>> immediate needs, that leaves 3458 MB that would be unused, so it
>>> temporarily gets used for caching, if the 71 MB is used up, the cache
>>> will be lowered and that memory become available for use ... no point
>>> in letting memory be unused when they system can benefit from using it
>>> as cache.
>>
>> Exactly. Cache memory is essntially mirroring the disk(s). If it gets
>> full the disk is activated and any writable data written to it. Read
>> data is simply discarded.
>>
>> Why the Pi is using swap is another matter entirely.
>>
>> If it bothers you stop it, or configure a small ramdisk as swap.
>>
>Putting swap space in a ramdisk doesn't help because that is (obviously!)
>mapped into RAM, and so will merely reduce the RAM available for other
>purposes. If you want to use fixed swap space, rather than the default
>swap file, create a dedicated swap partition on spinning rust or an SSD,
>BUT I would not put one on an SD card if its at all frequently used. A
>reasonable size for fixed swap space is twice RAM size.
>
>Use gparted or one of the older command-line tools (cfdisk, fdisk etc.)
>to manage device partitioning. Running "apropos partition" will show you
>which partition managers are installed and, as always, 'man' describes
>what each can do and how to use it. Swap partitions don't need to be
>formatted after creation.
>
>
>--
>Martin    | martin at
>Gregorie  | gregorie dot org

OK, thank everybody for the replies.
So it is a swap file... did not even know that.
Anyways it does not explain why all programs now seem to use swap space.
I did the following as test / solution perhaps:
Added
# clear cache every 15 minutes to prevent swap space usage and swap partition
overflow due to too little free memory left
0,15,30,45  *   *   *   *       /bin/echo 3 > /proc/sys/vm/drop_caches
in /root/crtab
so every 15 minutes the cache is emptied and more memory stays available:
MiB Mem :   3906.0 total,   2688.8 free,    377.1 used,    840.1 buff/cache
MiB Swap:    100.0 total,     19.7 free,     80.3 used.   3379.0 avail Mem

Seem to have absolutely no effect on recording cameras,
but at least 2 GB free memory is always available.
Now the 19.7 free swap space has been constant for at least an hour.

Then I started first firefox, swap space stayed the same.
Then also started chrome browser, swapspace now increased to
MiB Mem :   3906.0 total,   2890.2 free,    378.1 used,    637.7 buff/cache
MiB Swap:    100.0 total,     20.2 free,     79.8 used.   3380.0 avail Mem

closing both firefox and chrome does NOT release the new swap space,
it stays at 20.2 free,
so it seems other apps were forced to use swap, 2 GB not enough ??? LOL

Indeed it is then probably safer to add a swap partition with huge size.

But IMO this is a basic problem in Linux.
An ever growing swap space usage is a killer in the long run,
be it in a file or on a disk.
 ?

--- SoupGate-Win32 v1.05
* Origin: Agency HUB, Dunedin - New Zealand | FidoUsenet Gateway (3:770/3)

SOURCE: echomail via QWK@docsplace.org

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.