四博智联产品售后

 找回密码
 立即注册
搜索
查看: 17901|回复: 0

NodeMCU启动的时候编译文件 内存不足解决方法 (not enough memory)

[复制链接]

0

主题

0

帖子

0

积分

新手上路

Rank: 1

积分
0
发表于 2015-6-17 09:39:07 | 显示全部楼层 |阅读模式
NodeMCU启动的时候编译内存不足,会出现如下提示:
  1. lua: not enough memory
复制代码

或者:
  1. PANIC: unprotected error in call to Lua API (not enough memory)
复制代码



Doitcar的程序是在init.lua里面对指定的文件进行编译。
由于lua解释器在启动的时候占用较多内存,此时如果进行文件编译有可能出现内存不足。
解决方法是:在启动的时候,利用定时器延迟一定的时间后再启动编译。
init.lua文件改为下面代码即可:
  1. print("\n")
  2. print("ESP8266 Started")
  3. tmr.alarm(1, 1000, 0, function()
  4.         local exefile="sta"
  5.         local luaFile = {exefile..".lua","DoitCarControlSTA3.lua"}
  6.         for i, f in ipairs(luaFile) do
  7.                 if file.open(f) then
  8.                   file.close()
  9.                   print("Compile File:"..f)
  10.                   node.compile(f)
  11.                   print("Remove File:"..f)
  12.                   file.remove(f)
  13.                 end
  14.          end

  15.         if file.open(exefile..".lc") then
  16.                 dofile(exefile..".lc")
  17.         else
  18.                 print(exefile..".lc not exist")
  19.         end
  20.         exefile=nil;luaFile = nil
  21.         collectgarbage()
  22. end)
复制代码



回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|四博智联 Inc. ( 粤ICP备15034758号-1

GMT+8, 2024-4-16 13:26 , Processed in 0.061059 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表