Skip to content

Instantly share code, notes, and snippets.

View craigloewen-msft's full-sized avatar

Craig Loewen craigloewen-msft

View GitHub Profile
@craigloewen-msft
craigloewen-msft / autoMemoryReclaim.sh
Created September 18, 2023 20:01
Auto memory reclaim shell script
#!/bin/bash
# Put under /etc/autoMemoryReclaim.sh
# set variables at the top
low_cpu_usage=50 # Note: We work with integer percentages (e.g., 50%)
idle_time=2 # Minutes
cached_memory_limit=1000 # MB
percent_memory_to_reclaim=5 # Percentage as an integer
wait_period=3
[ 0.000000] Linux version 4.19.121-microsoft-standard (oe-user@oe-host) (gcc version 8.2.0 (GCC)) #1 SMP Fri Jun 19 21:06:10 UTC 2020
[ 0.000000] Command line: initrd=\initrd.img panic=-1 nr_cpus=12 swiotlb=force pty.legacy_count=0 console=ttyS0,115200 debug
[ 0.000000] KERNEL supported cpus:
[ 0.000000] Intel GenuineIntel
[ 0.000000] AMD AuthenticAMD
[ 0.000000] Centaur CentaurHauls
[ 0.000000] x86/fpu: Supporting XSAVE feature 0x001: 'x87 floating point registers'
[ 0.000000] x86/fpu: Supporting XSAVE feature 0x002: 'SSE registers'
[ 0.000000] x86/fpu: Supporting XSAVE feature 0x004: 'AVX registers'
[ 0.000000] x86/fpu: xstate_offset[2]: 576, xstate_sizes[2]: 256
[ 0.000000] Linux version 4.19.121-microsoft-WSL2-standard (oe-user@oe-host) (gcc version 8.2.0 (GCC)) #1 SMP Thu May 14 20:25:24 UTC 2020
[ 0.000000] Command line: initrd=\initrd.img panic=-1 nr_cpus=12 swiotlb=force pty.legacy_count=0 console=ttyS0,115200 debug
[ 0.000000] KERNEL supported cpus:
[ 0.000000] Intel GenuineIntel
[ 0.000000] AMD AuthenticAMD
[ 0.000000] Centaur CentaurHauls
[ 0.000000] x86/fpu: Supporting XSAVE feature 0x001: 'x87 floating point registers'
[ 0.000000] x86/fpu: Supporting XSAVE feature 0x002: 'SSE registers'
[ 0.000000] x86/fpu: Supporting XSAVE feature 0x004: 'AVX registers'
[ 0.000000] x86/fpu: xstate_offset[2]: 576, xstate_sizes[2]: 256
PS C:\Users\crloewen> wsl --help
Copyright (c) Microsoft Corporation. All rights reserved.
Usage: wsl.exe [Argument] [Options...] [CommandLine]
Arguments for running Linux binaries:
If no command line is provided, wsl.exe launches the default shell.
--exec, -e <CommandLine>