← index #4029Issue #175
Related · medium · value 1.329
QUERY · ISSUE

esp32: UDP broadcast via sendto causes memory leaks/ENOMEM error

openby dir-abletonopened 2018-08-06updated 2020-06-11
port-esp32

I described this in the uP forum:

https://forum.micropython.org/viewtopic.php?f=18&t=5063&p=28953#p28953

on further investigation, I found that commenting out

https://github.com/micropython/micropython/blob/master/ports/esp32/modsocket.c#L485

made the problem disappear - by disabling the actual functionality of course. To my uninitiated eye, this looks like a SDK issue, but at the same time there seems to be some dependency to the gc calls as documented in the forum post. Any suggestions on to get to the bottom of this?

CANDIDATE · ISSUE

Getting ENOMEM error after several calls to urequests.post()

closedby jdeltoftopened 2017-05-05updated 2022-09-22

I'm running a nodeMCU setup where every 30 seconds I'm calling urequests.post() to post a bit of data to influxdb running on a raspberry pi. It works great for 5-10 minutes and then it starts getting ENOMEM errors and resets eventually. I tried doing a gc.collect() along with my calls to post but didn't seem to help. Is there any other suggestions anyone can think of? Any debugging I should gather? gc.free_mem etc?

4 comments
pfalcon · 2017-05-05

Please see if http://docs.micropython.org/en/latest/esp8266/esp8266/general.html#scarcity-of-runtime-resources rings a bell. If it doesn't, please explain way, and we'll try to improve it.

jdeltoft · 2017-05-05

Sorry for jumping the gun on this. Got a reply on the forum that I probably made the common mistake and sure enough... I forgot to call res.close(). <embarrassed look>

whatdtech · 2022-04-06

problem is with urequests library, if you can switchback to usockets and close the socket before timeout then works fine.

Keelando · 2022-09-22

Was also struggling with this one, but its actually outlined in the docs

It's mandatory to close response objects as soon as you finished
working with them. On MicroPython platforms without full-fledged
OS, not doing so may lead to resource leaks and malfunction.
r = requests.get(...)
r.close()

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied