Skip to content

Instantly share code, notes, and snippets.

@pythoninthegrass
Forked from anildigital/cleanup_swap.md
Last active June 26, 2023 17:06
Show Gist options
  • Save pythoninthegrass/52a4642fc31a7e110fe1145608b0e3df to your computer and use it in GitHub Desktop.
Save pythoninthegrass/52a4642fc31a7e110fe1145608b0e3df to your computer and use it in GitHub Desktop.

Revisions

  1. pythoninthegrass revised this gist Jun 26, 2023. 2 changed files with 22 additions and 34 deletions.
    34 changes: 0 additions & 34 deletions cleanup_swap.md
    Original file line number Diff line number Diff line change
    @@ -1,34 +0,0 @@
    ### To see current swap usage
    ```
    sysctl -a | grep swap
    ```

    ### Use only when when your system is in a very bad shape

    ```
    $ sudo pkill -HUP -u _windowserver
    ```

    ### To monitor, what's creating/updating these swap files, run:

    ```
    $ sudo fs_usage | grep swapfile
    ```

    ### Or for page ins/outs, run:

    ```
    $ sudo fs_usage | grep PAGE_
    ```

    ### To see what WindowServer process is doing exactly, run:

    ```
    $ sudo spindump -reveal $(pgrep WindowServer)
    ```

    ### or for kernel_task, run:

    ```
    $ sudo spindump -reveal 0
    ```
    22 changes: 22 additions & 0 deletions swap_off.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    #!/usr/bin/env bash

    # To see current swap usage
    sysctl -a | grep swap

    # Monitor swap usage
    vm_stat 60

    # Use only when when your system is in a very bad shape
    sudo pkill -HUP -u _windowserver

    # To monitor, what's creating/updating these swap files
    sudo fs_usage | grep swapfile

    # Or for page ins/outs
    sudo fs_usage | grep PAGE_

    # To see what WindowServer process is doing exactly
    sudo spindump -reveal $(pgrep WindowServer)

    # or for kernel_task
    sudo spindump -reveal 0
  2. @anildigital anildigital revised this gist Apr 27, 2020. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions cleanup_swap.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,8 @@
    ### To see current swap usage
    ```
    sysctl -a | grep swap
    ```

    ### Use only when when your system is in a very bad shape

    ```
  3. @anildigital anildigital created this gist Apr 27, 2020.
    29 changes: 29 additions & 0 deletions cleanup_swap.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    ### Use only when when your system is in a very bad shape

    ```
    $ sudo pkill -HUP -u _windowserver
    ```

    ### To monitor, what's creating/updating these swap files, run:

    ```
    $ sudo fs_usage | grep swapfile
    ```

    ### Or for page ins/outs, run:

    ```
    $ sudo fs_usage | grep PAGE_
    ```

    ### To see what WindowServer process is doing exactly, run:

    ```
    $ sudo spindump -reveal $(pgrep WindowServer)
    ```

    ### or for kernel_task, run:

    ```
    $ sudo spindump -reveal 0
    ```