Subject: bug#77240: 30.1; Native-comp causing large memory leak

From: Eli Zaretskii <[email-masked]>
Date: Mon, 24 Mar 2025 20:30:47 +0200

> Date: Mon, 24 Mar 2025 16:23:49 +0100
> From: N Winkel <[email-masked]>
> 
> Evaluating the following snippet in 'emacs -Q' after removing any
> relevant eln-cache gives me memory leaks that don't seem to have
> an upper limit (largest I've had before killing was 10G):
> 
> (require 'package)
> (add-to-list 'package-archives '("melpa" . 
> "https://melpa.org/packages/") t)
> (package-initialize)
> 
> (use-package smartparens
> :config (require 'smartparens-config))
> 
> (defun +select-buffer-in-side-window (buffer alist)
> "Display BUFFER in a side window and select it, ALIST controls where it 
> opens."
> (let ((window (display-buffer-in-side-window buffer alist)))
> (select-window window)))
> (add-to-list 'display-buffer-alist
> '("\\*\\(?:Warnings\\|Compile-Log\\|Messages\\)\\*"
> (+select-buffer-in-side-window)))
> 
> This opens a Warnings popup buffer that displays "🚫 Warning 
> (native-compiler): "
> many times over with a single bit of information that is only sometimes 
> visible:
> "smartparens-config.el:96:24: Warning the function 
> 'org-element-property' is not
> known to be defined." which doesn't seem relevant. Here's a link to a 
> screenshot
> after evaluation: https://winkel.wolkesicher.de/index.php/s/HNTcdQMLCWNJ7Zq
> 
> Any interaction with the window after evaluating the snippet freezes the
> window, but cpu (100% on a single core) and memory usage continue, with
> memory rising at what appears to be a steady rate. The first couple
> seconds have separate processes that have high memory usage, but after
> that it all goes to the main 'emacs -Q' process.
> On my system it reaches over 2G within 3min.
> 
> Adding (run-with-timer 0 10 'malloc-trim) does not seem to help, nor
> does adding (malloc-trim) between statements.

Why do you say this is related to native-compiler?

Adding Andrea and Martin in the hope that they will have comments or
insights.