[HN Gopher] Monterey's memory leak and how to avoid it
       ___________________________________________________________________
        
       Monterey's memory leak and how to avoid it
        
       Author : llimllib
       Score  : 88 points
       Date   : 2021-11-15 14:02 UTC (9 hours ago)
        
 (HTM) web link (eclecticlight.co)
 (TXT) w3m dump (eclecticlight.co)
        
       | pwthornton wrote:
       | This explains why the behavior is so inconsistently seen. I
       | haven't seen it on my three macs and others have had their
       | systems crippled by it.
        
       | garblegarble wrote:
       | The title incorrectly implies implies this is the only bad memory
       | leak in Monterey (even though the author acknowledges it's not
       | the only in an edit complaining about 'comment bombing').
       | 
       | While the pointer one may be the worst culprit, it's definitely
       | not the only one - every few days I see Control Center using >3GB
       | (once force-killed, it goes back down to 26MB). It's not a
       | massive issue on my machine (I just check memory usage every day)
       | but it gives a very bad impression that Apple haven't fixed it
       | yet.
       | 
       | I'm sure is especially challenging for non-technical users who're
       | more likely to be on a lower-memory system and run out of memory
       | regularly
        
         | sys_64738 wrote:
         | What is "Control Center"? I don't have such an app on my system
         | running Monterey.
        
         | DavidPP wrote:
         | You made me check only me end, and indeed Control Center was
         | sitting at 5.19gb.
        
         | heartbreak wrote:
         | I think the workaround for the Control Center leak is to turn
         | off Airplay target mode in System Pref -> Sharing and then
         | restart (kill) the CC process.
        
         | marcellus23 wrote:
         | > it gives a very bad impression that Apple haven't fixed it
         | yet.
         | 
         | This suggests that it's a common or even universal problem, but
         | are you sure that's the case? I've never seen Control Center
         | use an inordinate amount of memory -- it may very well be a
         | rare or unique issue.
         | 
         | edit: I see someone else ran into it -- fair enough! Still, I
         | think it's funny how often I see "I keep running into this bug,
         | why haven't they fixed it!" on HN, considering how software
         | developers should know, better than anyone, how often bugs are
         | hard-to-reproduce edge cases.
        
           | xenadu02 wrote:
           | >I think it's funny how often I see "I keep running into this
           | bug, why haven't they fixed it!" on HN, considering how
           | software developers should know, better than anyone, how
           | often bugs are hard-to-reproduce edge cases.
           | 
           | We (software engineers) usually aren't any better than other
           | customers despite having the same issues ourselves.
           | 
           | Everyone ships bugs that seem obvious in retrospect. Everyone
           | has some small % of customers who hit a bug yet scream loudly
           | about how terrible quality is and how stupid we are for
           | shipping something so obvious. Everyone has had to make last-
           | minute calls "fix or ship?", knowing that every accepted fix
           | has a chance of introducing a new potentially worse bug.
           | Anyone who deals with hardware understands what delaying
           | software can mean.
           | 
           | If you haven't experienced these things then you just haven't
           | operated at large scale yet.
           | 
           | IMHO I think it is perfectly fine. When you're the customer
           | complain about whatever bothers you. That's valuable
           | feedback.
        
             | marcellus23 wrote:
             | > IMHO I think it is perfectly fine. When you're the
             | customer complain about whatever bothers you. That's
             | valuable feedback.
             | 
             | I mean sure, but you just said yourself how irrational it
             | is. I think it's possible to complain without acting
             | entitled about it.
        
           | throwntoday wrote:
           | I've seen enough people talking about it that I don't believe
           | it is unique.
           | 
           | I check my activity a couple times a day, and there doesn't
           | appear to be any correlation between use and control center
           | randomly taking >1GB of memory. I could for instance check
           | when all apps are closed and it's memory usage is high but
           | then after a long day of work it's still floating around
           | 30MB. I'm baffled at what the issue actually is but control
           | center appears to be processing a lot more data now as all
           | media seems to pass through it in some way.
        
             | marcellus23 wrote:
             | Control Center is also built using SwiftUI I believe.
             | SwiftUI still has a lot of rough edges especially on Macs,
             | I wonder if that's the issue?
        
             | Isthatablackgsd wrote:
             | Is the background apps closed as well? I wonder if you have
             | a background app that are constantly using or interacting
             | with the system that Command Center need to keep it
             | updated? Honestly, I am just throwing out possible idea.
             | 
             | I recalled there was an issue with Google Play service
             | consuming higher usage than other apps when Play is not in
             | focus. Turns out it is apps that are using Google Play
             | services for GCD or GSM, causing wake lock issues. The
             | reason why they are seeing the higher usage because the
             | Google Play services is the one that are interacting with
             | the system and the network and it is the third party app
             | that initiate the call which put Google Play service as
             | scapegoat. Unfortunately, Android phone does not have a way
             | to separate them.
             | 
             | I wonder if this also applies in macOS. I remember I had a
             | issue with Windows service that are consuming a high cpu
             | usage which is abnormal. I ran malware and antivirus
             | scanning and come up clean. It still didn't explain why the
             | service is so high. So I used ProcMon (Process Monitor) to
             | keep a log of what is interacting with the service. It took
             | me a while to filter it out because it have 100 new entries
             | every second for that service. Found out it that third
             | party app that are hitting the service hard, I assume the
             | app was misbehaving and caused this. So I force closed the
             | app and restart it, it went back to normal.
             | 
             | I wonder if macOS have process monitor for checking this
             | out?
        
       | mzs wrote:
       | source: https://bugzilla.mozilla.org/show_bug.cgi?id=1735345#c18
       | 
       | ---
       | 
       | Markus Stange [:mstange]
       | 
       | Comment 18 * 1 month ago * Edited
       | 
       | I've filed FB9704004 about this.                   -[NSCursor
       | set] appears to be leaking images, causes 70GB leak in Firefox
       | This appears to be a regression in one of the recent macOS
       | Monterey Betas.              Two Firefox users reported a very
       | large memory usage. We're tracking this in
       | https://bugzilla.mozilla.org/show_bug.cgi?id=1735345 .         We
       | have a memory report which blames the allocations on this stack:
       | #02: _malloc_zone_malloc[/usr/lib/system/libsystem_malloc.dylib
       | +0x1e770]         #03: createImageWithSizeRenderInstructions[/Sys
       | tem/Library/PrivateFrameworks/AccessibilitySupport.framework/Vers
       | ions/A/Frameworks/AccessibilityFoundation.framework/Versions/A/Ac
       | cessibilityFoundation +0x7430]         #04:
       | -[_AXFMouseCursorGeneratorLayer _createImageForScale:color:][/Sys
       | tem/Library/PrivateFrameworks/AccessibilitySupport.framework/Vers
       | ions/A/Frameworks/AccessibilityFoundation.framework/Versions/A/Ac
       | cessibilityFoundation +0x66e0]         #05:
       | -[_AXFMouseCursorGenerator createImageForScale:][/System/Library/
       | PrivateFrameworks/AccessibilitySupport.framework/Versions/A/Frame
       | works/AccessibilityFoundation.framework/Versions/A/AccessibilityF
       | oundation +0x5064]         #06: -[_AXFMouseCursorGenerator _regis
       | terWithName:connection:isGlobal:setActive:seed:][/System/Library/
       | PrivateFrameworks/AccessibilitySupport.framework/Versions/A/Frame
       | works/AccessibilityFoundation.framework/Versions/A/AccessibilityF
       | oundation +0x5418]         #07: _AXFCursorSetAndReturnSeed[/Syste
       | m/Library/PrivateFrameworks/AccessibilitySupport.framework/Versio
       | ns/A/Frameworks/AccessibilityFoundation.framework/Versions/A/Acce
       | ssibilityFoundation +0x70b8]         #08: _AXInterfaceCursorSetAn
       | dReturnSeed[/System/Library/Frameworks/ApplicationServices.framew
       | ork/Versions/A/Frameworks/HIServices.framework/Versions/A/HIServi
       | ces +0x2d1d8]         #09: -[NSCursor _reallySet][/System/Library
       | /Frameworks/AppKit.framework/Versions/C/AppKit +0x1e01d0]
       | #10: -[NSCursor set][/System/Library/Frameworks/AppKit.framework/
       | Versions/C/AppKit +0x1e0050]              Firefox calls
       | -[NSCursor set] very frequently during mouse motions, so many
       | leaked images might accumulate.
        
       | thebean11 wrote:
       | > There was no significant change in memory used by WindowServer
       | (3.37 GB)
       | 
       | Isn't that high for WindowServer? I haven't seen mine over 1GB.
        
       | gnicholas wrote:
       | I recently ran into a memory leak in Mojave (Mail was consuming
       | 49 GB of RAM), so I finally upgraded to Monterey. The memory leak
       | is gone, but now I'm seeing incredible CPU usage in Mail (1/2 to
       | 3/4 of my MBP's total resources, while Mail is idle).
       | 
       | I called AppleCare and they said they are aware of the problem
       | and will be fixing it in an upcoming release.
        
         | officeplant wrote:
         | It's an improvement from Mail occasionally causing grey screens
         | of death on M1 machines in Big Sur.
        
       | still_grokking wrote:
       | Seeing all the comments here I'm asking myself once more how
       | people can bear such crappy products. Especially as the products
       | are overpriced on any reasonable scale.
       | 
       | With a stock Linux you _never_ see anything even close to all
       | those catastrophes.
       | 
       | I'm not aiming at a OS flame but honestly question how this is
       | bearable to otherwise mostly reasonable people. Is there a true
       | core to this Stockholm syndrome meme about Apple users? Why are
       | people using obviously extremely broken stuff, especially as it
       | costs at least one-third more than perfectly fine working stuff?
       | I just don't get that. Honestly!
        
         | dundarious wrote:
         | I have a standard AMD CPU+GPU, and Manjaro has spontaneously
         | rebooted (the hardest of crashes) at least 10 times in the last
         | 2 years. I use Windows 10 on this machine about 10 times more
         | often and in the same time-frame it has crashed _maybe_ once.
         | 
         | My first Linux install was Mandriva in 2001, followed quickly
         | by Slackware, then Debian, Ubuntu, Pop!OS and now I pretty much
         | exclusively use Arch and Manjaro. I'm pretty sure that in all
         | those 20 years, every time I use up almost all my RAM, the
         | system becomes entirely unusable, to the point where I can't
         | even interact enough to kill programs, and not even the OOM
         | saves the system from total lockup, so I need to power off and
         | on. I've _never_ had this experience on Windows. It gets slow,
         | but it can recover.
         | 
         | The only time where Windows (kernel) was less reliable for me
         | than Linux, as a desktop user, was when I had Windows Millenium
         | Edition -- when my journey all began.
         | 
         | I'd still say I prefer Linux, but it's largely because it's
         | better for my work on systems software. It's definitely not
         | nicer to use as a desktop if you hate crappy products and like
         | good ones.
        
           | still_grokking wrote:
           | That's once more not an answer to my question...
           | 
           | Regarding spontaneously reboots: I never ever experienced
           | this on Linux besides once having a hardware defect. (I would
           | check the RAM in your case first; Manjaro is an Arch
           | derivative so it incorporates the latest SW but it's not so
           | terribly unstable that it would crash every two month I
           | guess; not sure of course. I'm avoiding Arch for exactly the
           | reason not being stable enough cause it's extremely fresh
           | SW).
           | 
           | Regarding the unresponsiveness on low memory: That's an known
           | problem caused by a live-lock in the kernel. It has a few
           | solutions by now. Just have a look at Facebooks oomd (or one
           | of the solutions working in a comparable way):
           | 
           | https://facebookmicrosites.github.io/oomd/docs/overview
        
         | lmilcin wrote:
         | I have been using Linux since last millennium and I can tell
         | you there is no shortage of bugs.
         | 
         | Just right now I am fighting my Fedora upgrade and Pipewire
         | systems that are constantly reverting my custom configuration
         | that I wrote to prevent automatically suspending audio to my
         | external DAC. On a normal audio output it does not matter when
         | your audio stops sending analog signal, but mine is connected
         | over Toslink. When the signal stops the DAC on the other side
         | also shuts down. Then when the sound gets back it takes time
         | for it to turn on again (2s of silence + 2s of slow volume ramp
         | up) which is extremely annoying. This happens by default after
         | 30s of inactivity.
         | 
         | Unfortunately, Pipewire developers seem to be having some
         | pretty strange ideas about how to work with user configuration
         | (basically, don't care about it).
         | 
         | I had custom configuration and then it got overriden when they
         | decided to move configuration from /etc to somewhere in /usr.
         | Then I edited in /usr but it got overriden by fedora update
         | system the next time it has been updated (I guess I could have
         | predicted it). Then I followed documentation and edited in my
         | $HOME/.config but apparently this also stopped working
         | yesterday.
         | 
         | And I just want to keep my audio working. Don't get me started
         | on graphics or dev environment.
         | 
         | See, no shortage of frustration there...
        
           | still_grokking wrote:
           | I'm also using Linux since the last millennium. I can't
           | confirm such issues.
           | 
           | Using Fedora means using _experimental_ stuff. Pipewire for
           | example is not ready for prime time, so it has obviously
           | issues. Simple as that.
           | 
           | But I don't say of course Linux is without bugs. Never seen
           | any more complex software without bugs... The point is how
           | grave those bugs are and how they could possibly pass QA.
           | Especially Apple has a comparably simple job here as they
           | only support officially a hand full of products which are
           | even build by themself.
           | 
           | And it's not only me who sees one catastrophe following the
           | other at Apple. Just have a look at the discussion thread on
           | the other current front page topic:
           | 
           | https://news.ycombinator.com/item?id=29229881
           | 
           | To repeat my question: How do people bear that? That's what I
           | just can't understand.
           | 
           | Again, I'm not interested in an OS flamewar. That Apple's
           | products are subpar is a fact at this point, and we don't
           | need to discuss that again. (Just follow the other HN
           | thread). The question is why people are still using this
           | stuff and not voting with their wallet (especially as it
           | would make their wallet more happy).
        
             | zsmi wrote:
             | > Again, I'm not interested in an OS flamewar. That Apple's
             | products are subpar is a fact at this point
             | 
             | That second sentence seems like it was specifically crafted
             | to start a flame war to me. You don't even mention on what
             | dimensions Apple products are subpar. All possible ones I
             | presume?
        
               | still_grokking wrote:
               | No it wasn't.
               | 
               | Please just have a look at the linked evidence, which
               | happens to be another discussion form the current front
               | page.
        
         | AlexCoventry wrote:
         | I'm getting one of the new macs because the hardware seems
         | great. I got one around the turn of the century for the same
         | reason (and mostly ran linux on it.)
        
           | still_grokking wrote:
           | That's a valid reason, I guess.
           | 
           | But the current hardware only works with that crappy Apple
           | software. So even the HW would be nice it's mostly unusable
           | by now.
        
         | VWWHFSfQ wrote:
         | Desktop Linux is absolutely riddled with bugs unless you have a
         | suitably generic hardware configuration and even then you will
         | very likely still have problems with:
         | 
         | - Audio
         | 
         | - Wifi
         | 
         | - Bluetooth
         | 
         | - External monitors
         | 
         | - Suspend/Resume and power management in general
         | 
         | - many other things
         | 
         | I abandoned it years ago. I just don't have time for that
         | anymore.
        
           | still_grokking wrote:
           | I didn't ask why you don't use Linux. (Additionally I can't
           | confirm any of the claimed problems; using Linux as a daily
           | driver for more than 20 years. All the mentioned things just
           | work OOTB since many, many years).
           | 
           | I asked why people are using an utterly broken OS where even
           | most basic stuff like memory management is defect. (Not even
           | asking how this could possibly pass any QA)...
           | 
           | Even if you think Linux isn't better, it can't be worse!
           | 
           | But Linux is free. (And actually doesn't have most of the
           | problems Apple has with even it's _own_ hardware).
           | 
           | So it's valid to ask how people bear using a broken system
           | and even paying for it more than elsewhere.
           | 
           | And to repeat myself form an answer given previously: That
           | Apple's software is utterly broken and you won't find
           | anything worse in the market is a fact at this point. Please
           | just follow the other front-page discussion:
           | 
           | https://news.ycombinator.com/item?id=29229881
        
             | josephg wrote:
             | > Even if you think Linux isn't better, it can't be worse!
             | 
             | It could be! The truth is complicated. I've been using a
             | ryzen desktop running mint for the last year and I just got
             | a M1 pro. I love both of these machines and I still don't
             | know which I want to be using as a daily driver. (Well, now
             | mint is set up how I like).
             | 
             | These macos bugs are real - and they feel like amateur hour
             | junk. As well as the memory leak I'm also running into a
             | bug on my M1 where WindowServer idles at 100% cpu after
             | I've been using my computer for awhile. I have no idea what
             | it's doing or what causes it, but the only way to fix it is
             | a reboot. (Or kill -9 the process, which logs me out and
             | closes all my programs anyway).
             | 
             | But Linux's bugs are different. I haven't rebooted my Linux
             | machine in ages. But on linux I'm annoyed by other things.
             | Lots of programs have broken smooth scrolling. Keyboard
             | shortcuts for moving the cursor around are inconsistent. I
             | can't use the Meta key in intellij as a modifier for some
             | reason - so I can't use my muscle memory shortcuts (and the
             | ctrl+shift+C is _awful_ as a copy shortcut in xterm!). I
             | use a trackpad on my desktop and the sensitivity is way off
             | - so i get misclicks all the time. App distribution is a
             | mess - flatpak, snap, apt, custom dpkgs and manual make  /
             | make install? All of the above? I accidentally ended up
             | with 2 copies of discord installed and didn't know which
             | one was "right".
             | 
             | Linux does the core engineering work right but often falls
             | down in frontend UX. (Its definitely getting better these
             | days though). Apple makes nice UX but their core
             | engineering is remarkably buggy. Apple please - I know you
             | think the market wants a new OS every year with new
             | features. You don't need a new font every year to compete
             | with cheap plastic x86 laptops. Please slow down and fix
             | your shit.
        
               | still_grokking wrote:
               | Thanks! That's the second reasonable answer I've got
               | until now.
               | 
               | It guess the distinction in "core engineering" and UX is
               | valid and helpful.
               | 
               | Adapting my point to it: Even the UX may be inconsistent
               | or even outright broken the resulting system is at least
               | somehow usable. If the core of a system is a tire-fire
               | nothing can work, and it makes no difference any more
               | whether you have the nicest UX or not.
               | 
               | One hint regarding the awful shortcuts: You could try to
               | switch CTRL and ALT or META. That's even a common "one
               | click" setting supported usually OOTB by the desktops.
               | Swapping those keys was the one truly right decision
               | regarding usability by Apple, which I welcome even not
               | liking the rest of the macOS UX.
        
             | Toutouxc wrote:
             | > That Apple's software is utterly broken and you won't
             | find anything worse in the market is a fact at this point.
             | 
             | No, it isn't, and even repeating it once more doesn't make
             | it any more true.
        
             | VWWHFSfQ wrote:
             | I should have expected "it works for me" to be the go-to
             | reply about why desktop linux is still terrible after all
             | these years.
             | 
             | The web browser is pretty much the best thing that ever
             | happened to linux users because now their $favorite_distro
             | is actually a viable desktop platform.
        
               | still_grokking wrote:
               | It may be "terrible"1 (even it works for me, and a lot of
               | other just fine) but it's not broken beyond usability at
               | least! And even if it would be as broken as macOS it's
               | free and supports much more hardware--compared to
               | something where you pay even a premium to be bound to
               | only one vendor.
               | 
               | So the main question remains.
               | 
               | 1 https://itvision.altervista.org/why.linux.is.not.ready.
               | for.t...
        
         | bkanber wrote:
         | My stock Ubuntu LTS desktop crashes all the time, about 3x a
         | week. Still can't figure out why.
         | 
         | I love linux, have used 4 different distros as my daily driver
         | for the last 15-20 years or so. Yet still my linux-using
         | friends and I have this joke: 'but will it hibernate?'
         | 
         | And to answer your question directly:
         | 
         | > Why are people using obviously extremely broken stuff
         | 
         | a) it's not obvious and b) it's not extreme. Apple products
         | work smoothly for most people most of the time. We're on hacker
         | news where the _entire point_ of this forum is the selection
         | bias around tech stories like this.
        
           | still_grokking wrote:
           | Have you considered a hardware defect? Even Ubuntu doesn't
           | crash the whole time. Also you see usually at least some
           | obvious reason in the logs if it's software related.
           | 
           | Regarding the "extremely broken stuff": I came here from
           | another thread:
           | 
           | https://news.ycombinator.com/item?id=29229881
           | 
           | I couldn't help to post the above after also seeing what's
           | described here. (Given all the down-votes maybe not the
           | smartest idea, but I honestly couldn't help :-)).
           | 
           | The problems are in my opinion indeed extreme and by now the
           | mess gets undeniable even to die-hard fans.
           | 
           | What makes me really scratch my head is why otherwise
           | reasonable people don't vote with their wallet and still buy
           | this things (even at a premium!).
        
         | zsmi wrote:
         | > With a stock Linux
         | 
         | What is a stock Linux?
         | 
         | Want to be amazed. Check this out:
         | https://en.wikipedia.org/wiki/List_of_Linux_distributions
         | 
         | I mean, there are family trees...
        
           | still_grokking wrote:
           | > What is a stock Linux?
           | 
           | Anything considered stable.
           | 
           | I wanted to avoid OS flamewar so I wasn't too specific. But
           | we are already there I fear...
           | 
           | Nobody it answering my question. Instead people point out
           | Linux isn't without bugs either. Even I never claimed that.
           | 
           | It's without almost daily catastrophes. That's a big
           | difference!
        
             | zsmi wrote:
             | >>> With a stock Linux you never see anything even close to
             | all those catastrophes. >> What is a stock Linux? >
             | Anything considered stable.
             | 
             | https://en.wikipedia.org/wiki/Tautology_(logic)
        
           | fragmede wrote:
           | It refers to a default install of any mainstream
           | distribution, with few modifications. Eg you're bound to run
           | into problems if you're running some strange window manager
           | with a funky desktop. By comparison, I'd expect a base
           | install with Gnome to mostly just work. Which it does with
           | supported hardware. eg _arandr_ (/whatever the GUI tool is)
           | works fine for arranging monitors.
        
         | sneak wrote:
         | Extremely broken is not an apt description. It's mostly minor
         | annoyances, and they usually get fixed over time if they affect
         | enough people. Apple isn't 100% unresponsive.
         | 
         | Linux is equally, or perhaps more broken in many ways.
        
         | matthewmacleod wrote:
         | The problem is that you're taking a relatively small selection
         | of comments--usually only posted by people who have experienced
         | a problem--and extrapolating an overall picture from it that's
         | probably not that reflective of reality.
         | 
         | I use both Linux and MacOS roughly the same amount day-to-day.
         | My experience is that they suffer from various niggly failures
         | and issues to roughly the same extent in practice. I've had the
         | Mac sometimes lose Bluetooth connections and need lots of
         | switching things on-and-off to work, in the same way I've had
         | NetworkManager drop off wifi with no apparent explanation. Or
         | PulseAudio suddenly deciding to use all my my CPU. Or weird
         | lock screen bugs galore!
         | 
         | The products are broadly fine and functional, priced somewhat
         | higher than commodity equivalents but in exchange for benefits
         | which are worth it for some people and not others. I would
         | gently encourage you to consider that other people likely
         | aren't idiots and are generally making decisions based on their
         | requirements, which in some cases will not match yours!
        
           | still_grokking wrote:
           | Thanks! First more reasonable answer that doesn't go into OS
           | flamewars.
           | 
           | > I would gently encourage you to consider that other people
           | likely aren't idiots and are generally making decisions based
           | on their requirements, which in some cases will not match
           | yours!
           | 
           | That's the core of my question actually! I spelled it even
           | out. I just don't get why reasonable people would buy such
           | things.
           | 
           | I'm actually not sure the amount of trouble is the same on
           | average: I'm not reading almost everyday about some obscure
           | catastrophes on Linux (like not working memory management
           | like here, not working mouse or keyboard, not working USB,
           | not working monitors, etc.). The other thing is Apple
           | supports only a fraction of the hardware Linux does. It
           | actually seems they don't do any QA. All that broken stuff
           | shouldn't ever reach end-customers. Especially as mostly all
           | that has to be done is to test against their own products.
        
         | prewett wrote:
         | I switch to macOS after successive updates of Ubuntu caused
         | audio to be a pain in the neck (due to PulseAudio), no longer
         | waking from sleep, and wifi not working. This was quite a while
         | ago. Audio still doesn't work by default on my Ubuntu 18
         | system.
        
       | mattl wrote:
       | Seeing this on latest Big Sur too.
        
       | speedgoose wrote:
       | Perhaps Apple should switch to a programming language with a
       | garbage collector.
        
         | yxhuvud wrote:
         | Apple uses Swift. Swift uses ARC which is a kind of garbage
         | collector (the naive and eager reference counting kind).
        
         | vlovich123 wrote:
         | I can write you a memory leak in any language you want. No GC
         | strategy can solve that as doing so is equivalent to solving
         | the halting problem (at least that's my intuition).
        
           | tylerhou wrote:
           | It's not equivalent; you can tag every pointer with a special
           | bit. Then statically you know the accessible roots at every
           | instruction pointer value, and you can simply traverse
           | accessible memory regions, following tagged pointers. Free
           | all memory that is not visited.
           | 
           | A decision problem equivalent to the halting problem might be
           | (depending on the language): does this code free all
           | allocated memory correctly (assuming no garbage collector)?
        
         | jshier wrote:
         | It's still unclear whether these are actual leaks (orphaned
         | references), unconstrained growth, or deallocated memory whose
         | blocks haven't been reclaimed by the OS. Automatic memory
         | management would only help with the first case, and both Obj-C
         | and Swift have it by default. Of course, it's entirely possible
         | that the sources of these leaks are written in another language
         | (C++ is fairly common) or Obj-C with ARC turned off (if that's
         | even still allowed within Apple).
        
       | ethbr0 wrote:
       | If true on causes, how did this get through QA?
       | 
       | A new feature, that when used leaks memory, in any application
       | that changes the cursor between pointer and something else
       | frequently.
        
         | dagmx wrote:
         | Memory leaks tend to be difficult to capture in most QA
         | settings.
         | 
         | You'd have to be running a build for significantly longer than
         | most people run their QA test suite for, focusing on specific
         | actions.
         | 
         | Unless the memory leak ratcheted up memory use immediately,
         | it's going to be hard to detect as a result.
        
           | josephg wrote:
           | This is why tools like valgrind are indispensable. You can
           | run your target process through your test suite with valgrind
           | (or apple's Instruments) and it'll tell you if _any_ memory
           | leaked. Even if it's just a few bytes.
        
             | tylerhou wrote:
             | I don't know if Valgrind (or Clang msan) would catch this
             | bug as it might not be associated with any calls to
             | *alloc/mmap/free/etc. Seems like a kernel issue, and I
             | don't know if Valgrind has the capability to peer that
             | deep.
        
             | lordnacho wrote:
             | There's more than one way to leak memory though.
             | 
             | One way is the classic where you get memory from an OS
             | call, and then you lose the pointer to it. Valgrind will
             | then correctly tell you that there's this memory that your
             | app can no longer access.
             | 
             | But you can also simply use more and more memory without
             | losing track of where it is. Say you have some function
             | that gets a new piece of memory and then stores the
             | pointer, again and again. Such a program isn't leaking
             | memory in the classic sense, but it's still using more and
             | more memory. Your tool won't know that this isn't supposed
             | to be happening.
             | 
             | IIRC a common way to leak memory the second way is in GC'ed
             | programs where for instance you might have a closure that
             | owns the pointer, thus the GC when it's marking the objects
             | does not think it needs to clean up the object at the next
             | sweep.
        
               | lupire wrote:
               | That's usually called a space leak, distinguishing space-
               | wasting program logic from explicit memory mismanagement.
               | Users of a program generally can't distinguish space leak
               | from memory leak, unless you inspect the heap to look for
               | growing chains or pools of similar objects.
        
       | sa1 wrote:
       | I got my first (Your computer has run out of memory) warnings
       | recently on an Intel Mac (MBP 2015), during normal laptop usage.
       | My pointer settings are already the default. Maybe the laptop is
       | already too old for Monterey.
        
         | gnicholas wrote:
         | It's possible that changing the pointer setting and changing it
         | back could help.
         | 
         | It is also possible that your MBP is too old to run Monterey
         | smoothly. I've noticed that my 2017 MBP (base model CPU) is
         | noticeably slower with common tasks like spotlight.
         | 
         | I'm sure apple is optimizing for their own chips these days,
         | and they don't mind if this results in worse performance on
         | Intel machines. It'll speed up the upgrade cycle, which is good
         | for them (and bad for us).
        
       | dang wrote:
       | Recent and related:
       | 
       |  _Memory leaks are crippling my M1 MacBook Pro_ -
       | https://news.ycombinator.com/item?id=29142157 - Nov 2021 (727
       | comments)
        
       | duffyjp wrote:
       | I'm on an intel iMac with Big Sur and 48GB of ram. I've had this
       | memory leak plague my system at least half a dozen times.
       | 
       | I just checked and I'm one notch up from "normal" on the cursor
       | size.
       | 
       | I tried setting it back but it's just too damn small on this 27"
       | 5K display. I guess I'll just crash for the time being.
        
       ___________________________________________________________________
       (page generated 2021-11-15 23:02 UTC)