Subject: bug#15946: a patch against emacs 24.3.1 for fixing the distnoted memory leak

From: SB <[email-masked]>
Date: Mon, 20 Jan 2014 21:32:03 +0900

Great detective work. I'd like to see the patch! ;)

Even if it's superseded by the next release (24.4), some people might
be stuck on 24.3 for whatever reason and right now this bug thread is
the best reference for information.

In the mean time, some more experienced people can look at the patch
and further isolate the relevant changes for a tighter patch or
confirm your work. People with the bug can build with your patch and
confirm whether this bug is fixed by it too.

On Mon, Jan 20, 2014 at 9:01 PM, Jonathan Payne <[email-masked]> wrote:
> This is FYI for people who do not want to wait for emacs 24.4 and cannot use one of the current nightlies to get around the Mavericks distnoted issue.
>
> I am not a Mac programmer unfortunately, so take this with a grain of salt. My analysis of the problem is this:
>
> 1) When Mavericks came out a memory leak was discovered and fixed by Jan D. who is a frequent contributor to ns (Next Step) emacs for Mac OS X.
>
> 2) His fix, I think, was to avoid calling Application.run 20 times / second by introducing a variable called "shouldKeepRunning" into the Application.run method.
>
> 3) Repeatedly calling Application.run was causing a 160 byte leak each time inside emacs. But I think it was also causing a problem with distnoted, and I am speculating (knowing NOTHING ABOUT IT) that each call to run() was causing some sort of registration with distnoted. That registration, I assume, creates some sort of context in distnoted that is substantially larger than 160 bytes. So the leak in emacs was relatively slow, the one in distnoted was much larger.
>
> This would also explain why distnoted would get slower as time goes by because it has hundreds of thousands of registrations, all for emacs, which I assume it was still trying to deliver notifications to, but really, I have no idea what I am talking about.
>
> So, I applied part of Jan D's patch to emacs-24.3 that addressed this particular problem, and presto-chango, the leak is gone, distnoted is happy, and all my current elisp packages work because it's still emacs-24.3 and not emacs-24.4 which I assume is what's being created in the trunk today.
>
> So - should I post this particular patch some place? Are other people interested in having this patch?
>
> JP
>
>
>
>