<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<div style="direction: ltr; font-family: Aptos, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Hi Simon,</div>
<div style="direction: ltr; font-family: Aptos, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
I’m going to ask the OPNSense team and get back to you.</div>
<div style="direction: ltr; font-family: Aptos, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="direction: ltr; font-family: Aptos, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Niten</div>
<div style="direction: ltr; font-family: Aptos, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div id="mail-editor-reference-message-container">
<div class="ms-outlook-mobile-reference-message skipProofing">
<meta name="Generator" content="Microsoft Exchange Server">
</div>
<div class="ms-outlook-mobile-reference-message skipProofing" style="text-align: left; padding: 3pt 0in 0in; border-width: 1pt medium medium; border-style: solid none none; border-color: rgb(181, 196, 223) currentcolor currentcolor; font-family: Aptos; font-size: 12pt; color: black;">
<b>From: </b>Dnsmasq-discuss <dnsmasq-discuss-bounces@lists.thekelleys.org.uk> on behalf of Simon Kelley <simon@thekelleys.org.uk><br>
<b>Date: </b>Friday, January 30, 2026 at 11:59 AM<br>
<b>To: </b>dnsmasq-discuss@lists.thekelleys.org.uk <dnsmasq-discuss@lists.thekelleys.org.uk><br>
<b>Subject: </b>Re: [Dnsmasq-discuss] Potential memory leak<br>
<br>
</div>
<div class="PlainText" style="font-size: 11pt;">I just sent SIGHUP twice in succession to the dnsmasq process in my<br>
OpenWRT router, with the new malloc-logging feature enabled.<br>
<br>
HUP frees a load of configuration and the re-reads it and I correlated<br>
all the memory freed by the second HUP with what was allocated in the<br>
first HUP.<br>
<br>
It's perfect. Every block is freed.<br>
<br>
<br>
This is a fairly old installation, so old libraries, etc, but the very<br>
latest dnsmasq code.<br>
<br>
The configuration it's re-reading is pretty small.<br>
<br>
I then tried your technique of hitting dnsmasq hard with many HUPs.<br>
<br>
I had to go up to half a million to see much effect, but I guess most of<br>
those were dropped since they will have arrived before the previous one<br>
was cleared.<br>
<br>
In any case I could see a reproducible rise of a few percent in the VSZ<br>
of the process each time.<br>
<br>
What's clear is that the configuration is stored in a _lot_ of small<br>
allocations, so re-reading a substantial configuration  will free a lot<br>
of small blocks and then malloc a lot of small blocks.<br>
<br>
A quick Google produces some complaints about the fragmentation<br>
performance of musl, which may be significant.<br>
<br>
Is your installation using musl as the C library, and is it possible to<br>
build dnsmasq against, say glibc to test?<br>
<br>
Nearly all of the memory management on dnsmasq that gets hit by<br>
answering DNS or DHCP requests avoid hammering the malloc system by<br>
building pools of free data structures that get re-cycled as needed.<br>
Once the pools have grown to equilibrium size, even a very busy server<br>
hardly uses the heap. I guess the configuration code to use the same<br>
policy, but it's a big re-write, and re-reading configuration on a<br>
sub-second timescale is an unlikely use-case.<br>
<br>
<br>
<br>
<br>
Cheers,<br>
<br>
Simon.<br>
<br>
<br>
<br>
<br>
<br>
On 30.01.2026 01:59, Y.Y. wrote:<br>
> *Hi Simon,*<br>
><br>
> I think Your suspicion about the configuration re-reading logic is spot<br>
> on. I have documented the reproduction and some analysis here: https://<br>
> github.com/openwrt/openwrt/issues/21729#issuecomment-3815442601<br>
> <<a href="https://github.com/openwrt/openwrt/issues/21729#issuecomment-3815442601" data-outlook-id="c003cb5f-a49d-43f6-8963-a6d01a946b5d">https://github.com/openwrt/openwrt/issues/21729#issuecomment-3815442601</a>><br>
><br>
> To assist with the debugging, I can provide an OpenWrt *Linux x86_64 VM<br>
> image* that consistently reproduces this memory leak. Please let me know<br>
> if this would be helpful for your investigation.<br>
><br>
><br>
> _______________________________________________<br>
> Dnsmasq-discuss mailing list<br>
> Dnsmasq-discuss@lists.thekelleys.org.uk<br>
> <a href="https://lists.thekelleys.org.uk/cgi-bin/mailman/listinfo/dnsmasq-discuss" data-outlook-id="d6785a93-6c06-4cef-b9ff-129708c4010d">
https://lists.thekelleys.org.uk/cgi-bin/mailman/listinfo/dnsmasq-discuss</a><br>
<br>
<br>
_______________________________________________<br>
Dnsmasq-discuss mailing list<br>
Dnsmasq-discuss@lists.thekelleys.org.uk<br>
<a href="https://lists.thekelleys.org.uk/cgi-bin/mailman/listinfo/dnsmasq-discuss" data-outlook-id="12d8efed-bc3a-497b-a68a-f3874955f6e9">https://lists.thekelleys.org.uk/cgi-bin/mailman/listinfo/dnsmasq-discuss</a><br>
</div>
</div>
</body>
</html>