Current Lua downloadable firmware will be posted here

User avatar
By marcelstoer
#63949
jankop wrote:Example from Marcel does not work for me.


What could be the reason it works for me but not for you? What does "does not work" mean anyway?

jankop wrote:I had to modify it a little.


And that's why it's running out of memory. I just quote the relevant lines:

jankop wrote:
Code: Select allconn:on("receive", function(client, request)
  ...
  conn:on("sent", function() client:close() print(node.heap()) end)
end)
--conn:on("sent", function() print(node.heap()) end)


The problem with your code is with closed upvalues. The on-receive callback function accesses the `conn` variable which was declared outside that callback function. It can, therefore, not be GCed. This is not the case in my example and thus my heap consumption is stable.
User avatar
By jankop
#63954
What could be the reason it works for me but not for you? What does "does not work" mean anyway? -

It is simple. The client does not connect to the server. I try Mozilla FireFox, Chrome or IE.
By me, the client waiting for to close the connection from the server side.
User avatar
By gschulz
#63959 marcelstoer, I'm not sure you were looking at what you thought you were looking at. Firstly, if you were using the test code you presented, it would not have worked. When you modified my code, you eliminated the client:close() statement that would be necessary to kick off the next iteration. Secondly, where I agree that your version is "prettier", I intentionally tried to not use local variables (i.e. "buf") so it didn't contribute to the memory leak. Thirdly, moving the conn:on("send"...) callback to the conn:on("receive"...) callback should have no affect. In fact, this is proven when running under 0.9.6. Others have been able to reproduce my findings. I'm going to try a minimum module build and see if there is a difference. I'll post my findings. BTW: Anyone have any other builds to test this on? Additional Data: I tested this on ESP07s and ESP12Es.
User avatar
By gschulz
#63962 Here are my results:

0.9.6 Standard build - Pass, I ran my test all night with more than 100000 iterations
1.5.4 Custom Build: 7 basic modules - Fail after 96 iterations
2.0.0 Custom Build: 7 basic modules - Fail after 190 iterations

Tested on a ESP12E