Closing unity doesn't clear RAM

Hi, I’ve been trying to use unity on a laptop of mine and have been struggling (which I think is because of what I’m trying to import, but this is just background info rn) so I have been paying g attention to my RAM, CPU, and GPU using system monitor.

Before I started using unity, my ram usage was as around 12GB, while I was using unity I was getting spikes to around 28GB, I closed unity and unity hub and now I’m at 21GB. Anyone know why it’s that high? My guess is because of whatever settings are used to make it so programs can be loaded quicker because they are stored in memory, is this correct or a wrong guess?

What system monitor are you using? If it differentiates between different kinds of memory use, check and see if the memory you are expecting to be freed up is “in use” by memory cache.

https://www.linuxatemyram.com/

Instead of actively purging pages from RAM when they are no longer in use, if no application needs the memory Linux will often just leave the data there. If an application wants the memory it can just overwrite the cache, so it doesn’t hurt anything and makes retrieving the data way faster if it ends up needing it again.

3 Likes

I am using the plasma system monitor, I don’t think I can see the cache specifically.

While it may be true it won’t effect much, it is kind of worrying to see and would be nice if the was a way you could set certain programs to clear and/or some way to “manually” clear it after the program closes.

There is no benefit to clearing the cache, but you can clear it on purpose if you want to. For example with this suggestion from the article linked above:

If, however, you find yourself needing to clear some RAM quickly for some reason, like benchmarking the cold-start of an uncached application, you can force linux to nondestructively drop caches using echo 3 | sudo tee /proc/sys/vm/drop_caches.

You could script that and tie it into applications closing if you want to.

It seems somewhat ironic to expend system resources forcefully purging the cache, just to make it appear that you are using fewer system resources…but I get it, the way Linux uses memory caching is unintuitive if you are not familiar with that concept.

3 Likes

In the past I wrote a service (using the above command and others) to flush my ram and lots of other cached information prior to suspending. Tidied things up, and I figured it was an extra security layer to reduce attack surfaces. I’m not so security conscious these days, so I haven’t used that service in a long time.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.