-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
"Not enough memory" issues. #457
Comments
This is a "how to" Q and not a "I have found a bug" issue. Please use the correct forum for asking this sort of Q: www.esp8266.com 😄 |
@TerryE It is not a how to question, it is a "nodemcu can't handle a 100 line program, it complains about not having memory for it" question. The program works, I'm not asking how to make it work. It doesn't work on nodemcu when you try to run all of its parts together, because as I said, it runs out of memory for some reason. So I suspect there is a memory leak somewhere or I'm doing something terribly wrong. I did try replacing all string concats on print method calls for multiple parameters and the issue persists. There is no specific method that makes it complain when I add it and it's really surprising to me it can't handle this program, as there isn't much that actually gets executed. |
I tried to run it, first with no settings file (ran fine, returned blank values), then with the settings file containing:
Ran it again, and it returned this error |
String value must be quoted. |
@dnc40085 What version of nodemcu are you using? Could you tell me how much heap you have available when you boot up? Could you please try adding this method and see if it runs for you? --Creates AP so that an Android device can give the ESP
--the SSID and password of the network it should connect to
--access the internet, and also the API key it should use
function create_ap()
wifi.setmode(wifi.SOFTAP); cfg = {};
cfg.ssid = DEVICE_TYPE.."-"..SERIAL_NUMBER;
cfg.pwd="(FAVEGA)";
print("Starting up AP with SSID "..cfg.ssid.." and password "..cfg.pwd);
wifi.ap.config(cfg);srv = net.createServer(net.TCP);status = "Waiting for settings.";
srv:listen(80, function(conn)
conn:on("receive", function(conn, payload)
print("------Received------");
print(payload);
print("--------------------");
if (string.find(payload, "GET / ")) then
conn:send("<h1>Status: "..status.."</h1>");
print("Answering");
elseif (string.find(payload, "POST / ")) then
for k, v in pairs(get_settings_from_request(payload:match(".+[\r\n](.-)$"))) do
print(".")
print(k.."="..v);
if (k == "SSID") then
SSID = v
print("Set SSID to "..SSID)
elseif (k == "PASSWORD") then
PASSWORD = v
print("Set password to "..PASSWORD)
elseif (k == "API_TOKEN") then
API_TOKEN = v
print("Set API token to "..API_TOKEN)
elseif (k == "DEVICE_ID") then
DEVICE_ID = v
print("Set device id to "..DEVICE_ID)
end
end
write_locals_to_fs()
conn:send("HTTP/1.1 200 OK\n<h1>OK</h1>");
end
end)
conn:on("sent", function(conn) conn:close() end);
end);
end @pastukhov what do you mean? Where is an unquoted string? |
The ESP8266 has very limited RAM and SPIFFS resources. Unfortunately these tend to get less with each version because we keep adding new features which leave even less of this resource for your app. Yes you can write an application where individual parts work successfully but the total won't fit in RAM. This is a limitation of the chipset and the programming technique used, and not a bug in itself. I could explain how to do this but I am not minded to on an issue list about bugs in the firmware. However in short, have you played with
If you structure your Lua this way then you will find that you can run surprisingly large Lua applications within the ESP8266 memory constraints. |
I'm using my own fork of the current dev096 branch that excludes the(MQTT, COAP, U8G, WS2812, CJSON) modules plus a few other changes(Increased firmware burn speed, Starting UART baud rate set to 115200 instead of 9600, no other major changes). What version are you using? In StationAP mode while disconnected with no init.lua, the heap is 20848, while connected to an AP it's 20344. When I add that code to the previous code it says
I think he's referring to the TerryE is right, this thread really does need to be continued on esp8266.com since the NodeMCU issues section is for bugs having to do with the firmware. |
Hello, we have some way to save memory, |
Also the bugs inside the program may cause this kind of issue... I have write some codes... which use about 400 hundred lines in total, it works well : ) |
@vowstar when new chip will be released? have you something to suggest? |
See #719 |
I have faced the same problem I Solved it. |
@mahersafadi, if you use the current master or dev then you will see that running lua source files are only about 10% than lc files now, because of my packed lineinfo patch. The other trick is to make your diffferent code phases ephemeral as I describe in my Unofficial FAQ. |
I get the same error ("not enough memory"). Could you please take a look at this commit and see what could be wrong? Before this change everything works. MacDada/RemoteTemperatureMonitor@a54116c The log:
|
@MacDada, you are using an extremely old and no longer supported build. This is the wrong place to ask about the consequences of doing this. |
@TerryE You were right. I've upgraded the flash and now my code works. Thanks! |
Hi MacDada I see I have the same build that you used. Could you maybe describe how you upgraded the flash and what files you have used to upgrade it? |
@HermanLacuna There is a section in the NodeMCU documentation called |
I have same issue of out of memory. |
Wrong answer to the problem. Strings are garbage collectable objects. If you load functions when you need them and correctly dereference them when you've done with them, then any strings that they use will be GCed as well. Read my FAQ in the documentation for more discussion on this. Alternatively wait a week or so and #2292 will a PR in dev so you can in practice have as many functions and string in flash and not in RAM that you want. |
Hello! I have the following code:
I send it to the esp8266 with nodemcu 0.96 (I tested with 0.95 too), try to run it and it says it is out of memory. Running print(node.heap()) before running it outputs around 20kB. Is something wrong with my lua? Note that this isn't the whole code I want to use, I had to remove parts and slowly add them until they didn't run anymore. It doesn't seem to matter what I add, I tried with different functions and it still complains about the same thing.
The text was updated successfully, but these errors were encountered: