Skip to content

Memory leak with undeleted files in /dev/shm #271

@whhone

Description

@whhone

Problem

On Linux, the memory usage goes up with diff-hl and does not go down even leaving Emacs.

Cause

diff-hl creates lots of files in /dev/shm for caching. There are two types:

  1. #!path!to!file.txt#.~<ref>~ <--- I think this is acceptable, and grows in a reasonable speed.
  2. buffer-content-<hash> <--- this grows very fast. 1 edit create 2 new files like this

These files are not being deleted even closing Emacs. /dev/shm is the ram disk and memory are leaked, until manually delete these files.

IMO, we at least want to get rid of (2) which grows fast and unlikely to be reused. (1) is arguable.

> ls /dev/shm
 buffer-content-1EgsD1   buffer-content-DTkJM1   buffer-content-ilaWBW   buffer-content-s4l4Pf
 buffer-content-1Kv4li   buffer-content-EkBipS   buffer-content-impgQ7   buffer-content-sR0uuo
 buffer-content-2Nylha   buffer-content-Eldlea   buffer-content-IRTkHi   buffer-content-t3ZUJi
 buffer-content-4hLfZg   buffer-content-exc1E5   buffer-content-iSNDOR   buffer-content-tf1eRN
 buffer-content-5tvjAG   buffer-content-fMk9ga   buffer-content-jk5c6G   buffer-content-TlOKBz
 buffer-content-6FqxXE   buffer-content-fx5A2s   buffer-content-jTP6bM   buffer-content-TqIsX7
 buffer-content-7zY32v   buffer-content-fZeb8s   buffer-content-K0Ugao   buffer-content-tTOVGB
 buffer-content-91Chfq   buffer-content-g1iB0C   buffer-content-kkkhdo   buffer-content-UIlw98
 buffer-content-9hWsKk   buffer-content-gcY0pA   buffer-content-l4IhNi   buffer-content-uRZ0tZ
 buffer-content-a31Jaz   buffer-content-goYwNr   buffer-content-mZYusf   buffer-content-UtgCIK
 buffer-content-av3ZuT   buffer-content-H0tnEA   buffer-content-ndbQgF   buffer-content-Vfoz31
 buffer-content-b05a4n   buffer-content-hlK8m0   buffer-content-ofUTxp   buffer-content-vh2kEG
 buffer-content-b3kDXx   buffer-content-HOFZBD   buffer-content-oUMVZB   buffer-content-ViNaoA
 buffer-content-cs8zse   buffer-content-hu9w0h   buffer-content-OydYW5   buffer-content-VqWYxj
 buffer-content-DlTM8e   buffer-content-idvSDd   buffer-content-OZF0XA   buffer-content-VwRUSY
...

Verification

  1. If I change diff-hl-temporary-directory from /dev/shm to another directory, the above files are both written to that directory.
  2. If I disable diff-hl-mode, the above two types of files are no longer created in diff-hl-temporary-directory.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions