Skip to content

Instantly share code, notes, and snippets.

@hatsuyuki280
Created February 1, 2023 05:57
Show Gist options
  • Save hatsuyuki280/b8dd6285d205fd094630b84cbb178f44 to your computer and use it in GitHub Desktop.
Save hatsuyuki280/b8dd6285d205fd094630b84cbb178f44 to your computer and use it in GitHub Desktop.

优雅的帮助群友吃掉Oracle A1实例里面多余的内存quq
(将会直接吃掉2G,不够的话可以把下面的bs=20M改成30M quq)

只需要把上面的文件放在 /etc/systemd/system/ 目录下面
然后执行 systemctl enable --now just-eat-some-mem.service
就可以简单的在每次开机的时候增加额外的2G内存占用,如果临时需要大量内存,
希望释放占用也可以简单的执行 systemctl stop just-eat-some-mem.service

[Unit]
Description=Just eating some mem for keep Always Free Avalible
[Service]
Type=oneshot
ExecStart=/usr/bin/dd if=/dev/random bs=20M count=100 of=/dev/shm/Just-eating-some-mem.bin
RemainAfterExit=true
ExecStop=/usr/bin/rm /dev/shm/Just-eating-some-mem.bin
StandardOutput=journal
[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment