Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Linux by (6.1k points)

I am trying to run a c++ tool on Linux but it crashes due to a memory issue. I also checked out the RAM details of the machine. 

It says:

total used free shared buffers cached Mem: 15798 15747 50 0 15 12758 -/+ buffers/cache: 2972 12825 Swap: 8001 345 7655

And I found that there is no space available to run my application. 

So please tell me how I can clear the selected cache memory. It requires a minimum of 3GB of memory to run my application. I have not tried yet to erase the cache as it may kill the current application.

This is Redhat Linux where the tool takes at least 40 hours to reach the memory threshold limit. 

1 Answer

0 votes
by (11.7k points)

I have tried the solution down below on Ubuntu Linux and I was able to clear the cache.

You can try out this.

# echo 1 > /proc/sys/vm/drop_caches

Or

# echo 2 > /proc/sys/vm/drop_caches

# echo 3 > /proc/sys/vm/drop_caches

Caution: We use the # echo 3 > /proc/sys/vm/drop_caches command to clean up memory from pagecache, dentries and inodes.

Related questions

0 votes
1 answer
asked Feb 18, 2021 in Linux by rahulnayar01123 (6.1k points)
0 votes
1 answer
0 votes
0 answers
0 votes
1 answer
0 votes
1 answer
asked Feb 24, 2021 in Linux by sheela_singh (9.5k points)

Browse Categories

...