Skip to content

mdns_networking: Cannot allocate memory #11306

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
1 task done
JetForMe opened this issue Apr 27, 2025 · 3 comments
Open
1 task done

mdns_networking: Cannot allocate memory #11306

JetForMe opened this issue Apr 27, 2025 · 3 comments
Labels
Type: Question Only question

Comments

@JetForMe
Copy link

JetForMe commented Apr 27, 2025

Board

UM Feather S3

Device Description

I'm using a UM Feather S3 on a custom PCB with a few additional components to drive an LED matrix panel.

Hardware Configuration

I'm using a UM Feather S3 on a custom PCB with a few additional components to drive an LED matrix panel.

Version

v3.2.0

IDE Name

Arduino IDE 2

Operating System

macOS

Flash frequency

80

PSRAM enabled

no

Upload speed

921600

Description

I have been working on this project that I just added mDNS to. I use it to advertise the built-in web server, nothing more. After just a few minutes running, I get a ton of logging like this:

E (244434) mdns: Cannot allocate memory (line: 1767, free heap: 8337220 bytes)
E (244435) mdns_networking: Cannot allocate memory (line: 149, free heap: 8332324 bytes)
) mdns_networking: Cannot allocate memory (line: 149, free heap: 8330060 bytes)
mdns_networking: Cannot allocate memory (line: 149, free heap: 8327612 bytes)
1498327612 bytes)
E (244438) mdns_networking: Cannot allocate memory (line: 149, free heap: 8327612 bytes)
E (244438) mdns_networking: Cannot allocate memory (line: 149, free heap: 8330060 bytes)
244439) mdns_networking: Cannot allocate memory (li, free heap: 8327612 bytes)
E (244439) mdns_networking: Cannot allocate memory (line: 149, free heap: 8330060 bytes)
mdns_networking8327612 bytes)
E (244440) mdns_networking: Cannot allo149, free heap: 8330060 bytes)
E (244440orking: Cannot allocate memory (line: 149, free heap: 8327612 bytes)
E (244441) mdns_networking, free heap: 8325164 bytes)
E (244442) mdns_networking: Cannot allocate m, free heap: 8322716 bytes)
) mdns_networking: Cannot allocate memory (line: 149, free heap: 8320268 bytes)
E (244443) mdns_networking: Cannot allocate memory (line: 149, free heap: 8317820 bytes)
mdns_networking: Cannot allocate memory (line: 149, free heap: 8315372 bytes)
ree heap: 8315372 bytes)
mdns_networking: Cannot allocate mem, free heap: 8317820 bytes)
, free heap: 8320268 bytes)

Eventually I get a Core 1 panic'ed (corrupted stack) and the app restarts.

Sketch

//	Advertise mDNS…
	
#if true	
	Serial.println("Advertising mDNS…");
	if (!MDNS.begin("clock"))
	{
		Serial.println("mDNS init failed");
	}
	else
	{
		Serial.println("mDNS responder started");
		MDNS.addService("http", "tcp", 80);
	}
#endif

Debug Message

See above

Other Steps to Reproduce

Note that I don't think this is actually out of memory, if the free heap number is to be believed. But I can't find the code actually generating the line in the source. I'm using ESP Arduino 3.2.0

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.
@JetForMe JetForMe added the Status: Awaiting triage Issue is waiting for triage label Apr 27, 2025
@SuGlider
Copy link
Collaborator

@JetForMe -

Memory allocation can happen within many different memory spaces.
https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/system/mem_alloc.html

When malloc() is used within ESP32 Arduino, it can allocate from PSRAM, whenever the block is bigger than 4KB.
E (244441) mdns_networking, free heap: 8325164 bytes) indicates the total available memory, including PSRAM, which shall be most of it.

It is very possible that the DRAM available space is short and mdns is trying to allocate from it using something like heap_caps_malloc(MALLOC_CAP_8BIT), which will not try to allocate space from PSRAM, only from SRAM.

It is possible to check what is the DRAM remaining space by calling heap_caps_get_free_size(MALLOC_CAP_8BIT)
Check how the application is allocating memory in order to analyse what could be changed to make more room in DRAM.

@SuGlider
Copy link
Collaborator

@JetForMe - I have executed the example from
https://github.com/espressif/arduino-esp32/blob/master/libraries/ESPmDNS/examples/mDNS_Web_Server/mDNS_Web_Server.ino
This does the same as in the fragment code that you have posted in this issue.

Using Arduino Core 3.2.0.
I can browse http://esp32.local from my computer and I got a plain web page with Hello from ESP32 at 192.168.15.35.
It works fine. No error messages.

@SuGlider SuGlider added Type: Question Only question and removed Status: Awaiting triage Issue is waiting for triage labels Apr 29, 2025
@JetForMe
Copy link
Author

I can browse http://esp32.local from my computer and I got a plain web page with Hello from ESP32 at 192.168.15.35.
It works fine. No error messages.

Yeah, it works for quite a while, until it doesn't. It first reports the errors, then eventually reboots.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Question Only question
Projects
None yet
Development

No branches or pull requests

2 participants