You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

memory leak in macOS 12.6.3 Monterey

Hello


iMac late-2015, OS 12.6.3 (updated today), 32GB RAM ...


After the update to 12.6.3 I'm noticing a huge memory leak ... available memory just keeps dropping.


I've closed all apps. In activity monitor I terminated what I could find running - Dropbox, Malwarebytes, Quitter and EpocCam.


Using Memory Diag I can see the Cache just steadily growing and growing until there is very little RAM available. I've used Terminal's 'sudo purge' multiple times today. I've used Memory Diag to recycle the memory.


But the Cache keeps growing relentlessly and choking the available memory.


Does anyone know what's going on? Anyone else experiencing this problem?


It's really frustrating and it only began after the update to 12.6.3. Until yesterday I didn't have this problem.


Any suggestions on what can be done?


Thanks



iMac

Posted on Jan 25, 2023 2:14 PM

Reply
Question marked as Top-ranking reply

Posted on Jan 26, 2023 1:45 PM

The macOS 'purge' command basically flushes all your cashed file information and forced the file system to use slower and more power hungry storage I/O access to get it back.


I am not aware of an other way to force macOS to free up memory. What many memory clearers do is have their process keep allocating memory until they have forced macOS to push many apps to page and swap, then they free up all the memory and macOS puts it on the free list, and the user is happy.


Of course now macOS has to page back into memory an apps code and data when that app needs it, again using slower storage I/O and consuming more power.


An iMac does not care that much about power, as it is plugged into the wall outlet. Laptops do care.


And the user may (or may not) notice it takes longer to switch to an app that had all its stuff paged out. Then again, if they have a systemic problem of other apps consuming all of free memory, taking it down to a very low value, then identifying that app (or apps, or background daemon or agent) would be a good idea.


NOTE: a memory clearer app that forces other processes out of memory by consuming tons of memory and then freeing it, could be considered an app that uses a lot of memory until the memory free list is exhausted.


In many ways, how macOS behaves is similar to many other operating systems. The fine details are always different. Where other operating systems are Linux, AIX, Solaris, Tru64 UNIX (previously known as DIGITAL UNIX), OpenVMS (previously known as VAX/VMS), and before that the systems did not have virtual memory (Z80 CP/M, PDP-8 (no OS at all), PDP-11 (company specific OS not used anywhere else), a series of UNIVAC systems (both 1's complement 😱 and 2's complement binary 😁 )

12 replies
Question marked as Top-ranking reply

Jan 26, 2023 1:45 PM in response to PRP_53

The macOS 'purge' command basically flushes all your cashed file information and forced the file system to use slower and more power hungry storage I/O access to get it back.


I am not aware of an other way to force macOS to free up memory. What many memory clearers do is have their process keep allocating memory until they have forced macOS to push many apps to page and swap, then they free up all the memory and macOS puts it on the free list, and the user is happy.


Of course now macOS has to page back into memory an apps code and data when that app needs it, again using slower storage I/O and consuming more power.


An iMac does not care that much about power, as it is plugged into the wall outlet. Laptops do care.


And the user may (or may not) notice it takes longer to switch to an app that had all its stuff paged out. Then again, if they have a systemic problem of other apps consuming all of free memory, taking it down to a very low value, then identifying that app (or apps, or background daemon or agent) would be a good idea.


NOTE: a memory clearer app that forces other processes out of memory by consuming tons of memory and then freeing it, could be considered an app that uses a lot of memory until the memory free list is exhausted.


In many ways, how macOS behaves is similar to many other operating systems. The fine details are always different. Where other operating systems are Linux, AIX, Solaris, Tru64 UNIX (previously known as DIGITAL UNIX), OpenVMS (previously known as VAX/VMS), and before that the systems did not have virtual memory (Z80 CP/M, PDP-8 (no OS at all), PDP-11 (company specific OS not used anywhere else), a series of UNIVAC systems (both 1's complement 😱 and 2's complement binary 😁 )

Jan 26, 2023 6:56 AM in response to David King1

Refer to image below.


The Last Time this specific Application was updated was in Sept 2019 - 4 years ago.


Further, have yet to find any specific Info from the developers as to what Exact Version of macOS it support on.


Outside of that, it remains the ongoing issue of Who or What is Controlling what is kept in Memory (RAM )


Right now there is a " Tug of War " between the Operating System, Monterey and this Application.


It is the users computer to install whatever it ( OS ) allows to be installed and suffer any consequence including what is occurring now on the machine


To quote Albert Einstein " Insanity is doing the same thing over and over and expecting different results.” 

Jan 25, 2023 2:50 PM in response to David King1

Unless you are paging and swapping excessively, you WANT the operating system to use nearly all your memory, otherwise you wasted your money paying for extra RAM.


RAM is faster access then storage, so anything that can be kept in memory will be accessed faster. You said an iMac, but the same operating system is used on laptops, and accessing storage cost more power than accessing memory, so the more stuff kept in memory the less battery drain caused, so the laptop last longer between charges.


Again, unless you are seeing excessive paging and swapping, having lots of data cached is good.

Jan 25, 2023 6:11 PM in response to BobHarris

Thanks, Bob.


My concern is that this behaviour has begun after the update to 12.6.3. Also when the Cache balloons, the available RAM runs down to low MBs ... and my applications begin to choke.


That's why I have been using Terminal to free up RAM ('sudo purge') else things come to a standstill.


I've never seen the free memory run down like this before ... with all apps closed, it just keeps dropping like a stone. That's why I'm concerned that there's something else going on ...


Thanks for taking the time to respond.

Jan 26, 2023 8:12 AM in response to PRP_53

Thanks for taking the time to look into this.


If I understand you correctly, the app Memory Diag is potentially at fault for showing me an incorrect result. And this is based on the fact that it has not been updated since 2019.


I did use Terminal to purge the memory and it ends up freeing up a significant amount of memory.


Thanks.


p.s. There's no evidence that Einstein ever said that ... just sayin' ...


â˜źïž


Jan 26, 2023 11:50 AM in response to David King1

The following is a hack, and should not be needed, as chances are something is guilty of consuming all your memory besides file system cache.


But this hack will increase the minimum amount of free memory macOS will maintain that should allow running apps some freedom and avoid some spinning beachballs.


Increasing the minimum free memory size:


Applying the sysctl values in the following URL seems to greatly

minimize my macOS Spinning Beach Balls:


https://stackoverflow.com/questions/57674233


I have been experimenting with them, and after a few days, my system

seems to have a lot less Spinning Beach Balls, and the ones I get seem

to be less severe.


Basically add the following sysctl values to /etc/sysctl.conf:


    kern.vm_page_free_target=262144
    kern.vm_page_free_min=147456
    kern.vm_page_free_reserved=16384
    kern.vm_page_speculative_percentage=1
    vm.vm_page_background_exclude_external=0
    vm.vm_page_background_mode=1
    vm.vm_page_background_target=262144
    vm.compressor_timing_enabled=1


Then reboot.


If you want to just set them for the current booted system, then:


    sudo sysctl kern.vm_page_free_target=262144
    sudo sysctl kern.vm_page_free_min=147456
    sudo sysctl kern.vm_page_free_reserved=16384
    sudo sysctl kern.vm_page_speculative_percentage=1
    sudo sysctl vm.vm_page_background_exclude_external=0
    sudo sysctl vm.vm_page_background_mode=1
    sudo sysctl vm.vm_page_background_target=262144
    sudo sysctl vm.compressor_timing_enabled=1


and they will go away on the next reboot.


Storing the values in /etc/sysctl.conf will set them after every boot.


You can look at the current values using:


    sysctl kern.vm_page_free_target               \
           kern.vm_page_free_min                  \
           kern.vm_page_free_reserved             \
           kern.vm_page_speculative_percentage    \
           vm.vm_page_background_exclude_external \
           vm.vm_page_background_mode             \
           vm.vm_page_background_target           \
           vm.compressor_timing_enabled

memory leak in macOS 12.6.3 Monterey

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.