Because i can see it in the other client that the chunk was received, this takes about 2s.
Super! That sounds plausible over a 100 Mbps network that is operating efficiently.
What about if you transfer a 30-chunk file, as shown in the log? Can you see the chunks arrive in the other client about every 2 seconds?
Mem: 275.447 MB
publish chunk #30
Waiting 10s
Maybe the problem is the write speed to flash media by the other client.
I cant wait that much for each chunk.
We're in the diagnosis phase. Try with a 50 second Sleep.
Do the chunks arrive in the other client abut 2 seconds after they're sent? At one chunk per 50 seconds, you've got time to check the chunk numbers too, ie make sure that it's the
same chunk number that is received in the other client about 2 seconds after it's sent.
I expect that the mem will be free as soon the message was sent, at the latest when the other client received it (with QOS 1-2), and not 20-30s later..
I agree. That's what I'd expect too. But apparently that is not what's happening.
Before we can fix a problem, first we have to understand it.
I'm not proposing 50 second Sleeps as a
fix; I am proposing them as a
test to confirm that the memory is released after a chunk has been sent.
It could be that the MQTT system has a safety/quality feature than keeps messages for a minute or two aven after they've been sent, just in case there is a network fault and the hub/server/broker comes back with "
hey, there was a problem with that last message, can you please send it again?" request. For most MQTT use cases, eg under 100 kB per minute, that wouldn't be a problem.
I'm not saying that *is* what MQTT does, I'm just brainstorming possibilities that could explain what you're seeing.