Whickwithy

Q: Is there any way to manually clean up the memory other than a reboot?

I find that my memory gets cluttered with a bunch of junk, even if I close all of the applications and the only way to get it cleared up is to reboot the system.  It seems that there should be a way to clean up memory without rebooting.

Mac mini, OS X El Capitan (10.11)

Posted on Jan 23, 2016 3:59 PM

Close

Q: Is there any way to manually clean up the memory other than a reboot?

  • All replies
  • Helpful answers

Page 1 Next
  • by John Galt,

    John Galt John Galt Jan 23, 2016 4:01 PM in response to Whickwithy
    Level 8 (48,675 points)
    Mac OS X
    Jan 23, 2016 4:01 PM in response to Whickwithy

    If you are referring to memory (as opposed to disk space) then it is normal for OS X to use all of it. Memory that is not used is wasted. It is designed to be used that way to maximize performance.

  • by BobTheFisherman,

    BobTheFisherman BobTheFisherman Jan 23, 2016 4:02 PM in response to Whickwithy
    Level 6 (15,269 points)
    Jan 23, 2016 4:02 PM in response to Whickwithy

    El Capitan manages your memory. It will use as much as necessary all the time. There is no advantage to having unused memory. The only time to do something is if you are using a lot of swap or the there is a red indicator on your memory status.

  • by Whickwithy,

    Whickwithy Whickwithy Jan 24, 2016 3:23 AM in response to John Galt
    Level 1 (68 points)
    Mac OS X
    Jan 24, 2016 3:23 AM in response to John Galt

    I am referring to ram, yes, John.  The problem is this.

     

    I start my computer and the memory used is about 4 Gbytes with just the most basic programs open.  After a few days, when I return to the same set of basic programs, the computer now takes up about 6 Gbytes.  A few days after that, it's at 8GB.  You see the trend, I think.  This is a bad thing because, sooner or later, I start using compressed memory, which I assume is Apple's way of saying virtual memory or, even worse, they use some sort of compression scheme.  In any case, if I am using so much memory that it goes compressed, it is making the machine slower and will eventually cause disruptions, as well.  Getting rid of all of that wasted memory usage that is just cluttering up my ram, in some circles, used to be called garbage collection.  Now, I guess it is called reboot.

  • by John Galt,Helpful

    John Galt John Galt Jan 24, 2016 9:24 AM in response to Whickwithy
    Level 8 (48,675 points)
    Mac OS X
    Jan 24, 2016 9:24 AM in response to Whickwithy

    In that case there is a program or process leaking memory. That means it is not releasing memory when it should, and is considered a bug that only its developer can fix. Minor memory leaks are not unusual, but not to the extent you describe. Determining which program or process can be challenging.

     

    You can use the command leaks to identify whether a specific process is doing that, but its results can be inconclusive, and you have to know in advance which process you suspect is responsible. Most likely it will be a non-Apple product, though certain Apple software has been known to leak memory in rare circumstances.

     

    To potentially identify likely culprits use Activity Monitor, click the Memory tab, and sort processes by memory. Start by identifying the process with the largest memory value other than kernel_task.

     

    Compressed memory refers to memory that has been compressed using OS X's proprietary compression algorithm. Virtual memory refers to memory contents that have been written to mass storage, which is slower than RAM. If your Mac uses a rotational hard disk drive virtual memory usage will be very slow. Compressed memory is normal and your Mac's performance will not be affected by memory compression. On the other hand if the "memory pressure" graph becomes "red" it's an indication that your Mac is relying upon virtual memory, and its performance will degrade.

  • by Csound1,

    Csound1 Csound1 Jan 24, 2016 6:56 AM in response to Whickwithy
    Level 9 (50,297 points)
    Desktops
    Jan 24, 2016 6:56 AM in response to Whickwithy

    What is unused memory used for?

  • by Whickwithy,

    Whickwithy Whickwithy Jan 24, 2016 9:24 AM in response to John Galt
    Level 1 (68 points)
    Mac OS X
    Jan 24, 2016 9:24 AM in response to John Galt

    Compressed memory refers to memory that has been compressed using OS X's proprietary compression algorithm. Virtual memory refers to memory contents that have been written to mass storage, which is slower than RAM. If your Mac uses a rotational hard disk drive virtual memory usage will be very slow. Compressed memory is normal and your Mac's performance will not be affected by memory compression. On the other hand if the "memory pressure" graph becomes "red" it's an indication that your Mac is relying upon virtual memory, and its performance will degrade.

    So, compressed memory is as I suspected.  It has to have an effect.  Any messing with the memory, such as virtualizing it or compressing it, is not optimum and I never let it take place.  "Normal" is not accurate as it does not attempt to compress it unless there is some level of memory pressure, though it is a very small amount.  My memory used gets to about 10 - 12 GBs before it attempts to compress.  And, that's when I reboot.

    Thanks for the insights, I may look at the "leaks" stuff you talked about.  I think we are looking at things from a different perspective.  You are looking at it from the perspective of recovering from slowness or failure.  I am looking at it from the point of view that I don't ever want to incur either.  So, I don't think I have any specifically leaky programs.  They are all pretty standard programs.  It just I don't like to tolerate any leakage.  I use the programs pretty intensely and look for any use of compression and reboot.

     

  • by Csound1,

    Csound1 Csound1 Jan 24, 2016 9:31 AM in response to Whickwithy
    Level 9 (50,297 points)
    Desktops
    Jan 24, 2016 9:31 AM in response to Whickwithy

    Do you honestly think that compressed memory is as slow as swapping to disk? dream on.

     

    And if you do you can turn it off.

     

    1. Open up Terminal
    2. Type in: sysctl vm.compressor_mode
    3. (you should see 'vm.compressor_mode: 4' here, which indicates compressed swap is enabled)
    4. Type in the following: sudo nvram boot-args=vm_compressor=1
    5. reboot
    6. After reboot, verify it worked, open up Terminal, and do 'sysctl vm.compressor_mode'. You should see 1 printed.
  • by Whickwithy,

    Whickwithy Whickwithy Jan 24, 2016 9:37 AM in response to Csound1
    Level 1 (68 points)
    Mac OS X
    Jan 24, 2016 9:37 AM in response to Csound1

    Do you honestly think that compressed memory is as slow as swapping to disk? dream on.

     

    Of course not.  What a silly thing to say.

  • by Csound1,

    Csound1 Csound1 Jan 24, 2016 9:40 AM in response to Whickwithy
    Level 9 (50,297 points)
    Desktops
    Jan 24, 2016 9:40 AM in response to Whickwithy

    Then why are you suggesting it?

  • by John Galt,Helpful

    John Galt John Galt Jan 24, 2016 9:57 AM in response to Whickwithy
    Level 8 (48,675 points)
    Mac OS X
    Jan 24, 2016 9:57 AM in response to Whickwithy

    OS X's memory compression algorithm really will have negligible effect on performance. I have quantified it, and it is essentially zero. You are welcome to do so yourself.

     

    Compression will not occur unless you need more memory than you have. Adding more memory will delay the onset of memory compression. However, it is not a cure for memory leaks. If a process is leaking, it will take all available memory... eventually. If that "eventually" is on the order of weeks or months it's not worth investigating. Rebooting every so often, even if it's in response to an OS X update, is normal.

     

    They are all pretty standard programs.

     

    If to you "pretty standard" means products from Adobe, Google, or Microsoft, anything is possible. None of them have demonstrated any particular aptitude for — or apparent interest in — developing efficient OS X programs. "Anti-virus", "cleaning" products or similarly ill-conceived garbage is even worse. Identify the suspect processes using Activity Monitor as I suggested.

  • by Whickwithy,

    Whickwithy Whickwithy Jan 24, 2016 9:57 AM in response to John Galt
    Level 1 (68 points)
    Mac OS X
    Jan 24, 2016 9:57 AM in response to John Galt

    Oh, I agree.  But, negligible is not zero.  As I said, we are looking at things differently.  I want it running as cleanly and smoothly as possible.  Hmmm, maybe hard to explain.  And, yes, I am content to reboot occasionally.  It would just be nice if Apple took "leaks" one step further and had a "cleanup" button.  That is really what I was looking for.  "leaks" is certainly more complicated than a reboot.

     

    Wouldn't touch Adobe or Microsoft, unless under duress.  I wouldn't touch Chrome or Firefox if Safari had a decent way to control cookies.  Anti-virus, "cleaning" products and other ill-conceived garbage are out of the question.  Wouldn't touch them with a laser pointer.  It is definitely certain web locations that are accessed that cause the leaks but not much I can do about it.  I am not going to avoid Chrome or Firefox or certain websites because they leak. 

     

    I'm not sure that doing what you suggest would really benefit me under those conditions, right?  It's not like I'll be able to stop future leaks from the site or the browser, right?  It will just tell me where they are and it sounds more painful that just rebooting.  I think it has more to do with the particular websites than the browser.  I guess I could go and try Safari but I would have hundreds of cookies in the blink of an eye which annoys me greatly.  I've already tried pinging Apple about it as they seem to have made a motto out of not taking a users data.  That's fine but they leave one wide open to anyone else taking one's data by leaving the gates wide open - or completely closed.

  • by Csound1,

    Csound1 Csound1 Jan 24, 2016 10:00 AM in response to Whickwithy
    Level 9 (50,297 points)
    Desktops
    Jan 24, 2016 10:00 AM in response to Whickwithy

    Where do you plan on putting the tasks that would have need compressing for lack of real Ram, disk is slow, what's your plan?

  • by Whickwithy,

    Whickwithy Whickwithy Jan 24, 2016 10:07 AM in response to Csound1
    Level 1 (68 points)
    Mac OS X
    Jan 24, 2016 10:07 AM in response to Csound1

    It's a secret.

     

    Don't bother yourself.  Really.

  • by John Galt,

    John Galt John Galt Jan 24, 2016 10:23 AM in response to Whickwithy
    Level 8 (48,675 points)
    Mac OS X
    Jan 24, 2016 10:23 AM in response to Whickwithy

    I'm still waiting for you to describe the likely process or processes identified by Activity Monitor. Until then you cannot even get to Step 1.

     

    I recommend you forget about "cleaning up" memory. It is not necessary to concern yourself with such minutia, despite a plethora of popular "cleaning" apps that seek to convince gullible users of their benefit. Attempting to circumvent OS X's memory management will always lead to performance degradation, as well as the likelihood of accelerated hardware failure. If your Mac's performance begins to degrade for reasons you cannot explain, we can help you to troubleshoot that.

     

    All I can tell you is that El Capitan runs perfectly well in 4 GB RAM, running mostly (though not exclusively) Apple software, with no apparent leaks or degraded performance. I have tried and failed to degrade its performance by simultaneously running literally every app that I have installed. Of course flash memory helps.

     

    Here is a screenshot of AM:

     

    AM.png

     

    This particular Mac has been up for 10 days:

     

    Last login: Thu Jan 14 10:16:10 on console

    Restored session: Mon Jan 11 23:55:05 EST 2016

    MacBookAir2:~ john$ man leaks

    MacBookAir2:~ john$ w

    12:13  up 10 days,  1:57, 2 users, load averages: 1.53 1.45 1.41

    USER    TTY      FROM              LOGIN@  IDLE WHAT

    john    console  -                14Jan16 10days -

    john    s000     -                9:31      - w

    MacBookAir2:~ john$


    Maybe that will get you pointed in the right direction. Good luck.

Page 1 Next