How to release memory in Linux without the need to rest…

In Linux systems, there are several methods available to free up memory without needing to restart.

  1. To clear the page cache: Page cache is a part of memory that the kernel uses to cache filesystem data. You can use the following command to clear the page cache:
  2. Execute the command “sudo sync” followed by “sudo echo 1 > /proc/sys/vm/drop_caches” in the terminal.
  3. This command will release some memory back to the system.
  4. Clearing buffer cache: Buffer cache is a portion of memory used to cache block device data. You can use the following command to clear the buffer cache:
  5. Refresh the system’s memory cache by executing the commands “sync” and “echo 2 > /proc/sys/vm/drop_caches” with sudo privileges.
  6. This command will free up more memory, but it may result in some disk IO delays.
  7. Free up occupied pages: Sometimes, certain processes in the system can occupy a large amount of memory. You can use the following command to release the occupied pages:
  8. Execute the command “echo 1 > /proc/sys/vm/compact_memory” with superuser privileges.
  9. This command will attempt to free up occupied pages to provide more available memory.
  10. Terminate unnecessary processes: Use the kill command to end any unnecessary processes that are taking up a significant amount of memory in the system, in order to free up memory.
  11. Terminate the process with the specified process ID using sudo.
  12. By replacing with the actual process ID, you can kill a specific process.

Please be aware that before releasing memory, make sure that no important tasks or processes are relying on this memory. Additionally, these methods will only free up a portion of the memory, so if the memory usage on the system is still high, it may be necessary to consider increasing the system’s physical memory.

bannerAds