
lua
mengzhisuoliu
我有我自由你有感受
展开
-
lua 内存回收
内存回收器函数Lua 提供了以下函数collectgarbage ([opt [, arg]])用来控制自动内存管理:1, collectgarbage("collect"): 做一次完整的垃圾收集循环。通过参数 opt 它提供了一组不同的功能:2, collectgarbage("count"): 以 K 字节数为单位返回 Lua 使用的总内存数。 这个值有小数部分,所以只需原创 2017-12-29 14:29:07 · 1239 阅读 · 0 评论 -
在使用lua的tolua的内存泄露注意
最近在项目中使用vector的导出类为lua使用,在测试内存泄露的时候发现会有内存泄露,当时以为是哪一处的C++代码写得有问题,最后发现是脚本在调用vector中出现了问题,1.vector是一个local变量 ,local vc=new vector()2.自认为lua会在内存清理的时候调用collectgarbage自动清理内存的,后来发现这是不正确的,lua并不会自动清理这原创 2016-11-20 22:17:13 · 2303 阅读 · 0 评论 -
tolua++ 返回值
在pkg中导出这样的函数bool test( const char* szObj, const char* szMsg, bool blOK)在脚本中的返回值只有1个1.支持在lua脚本直接传递字符串2.支持在lua脚本中调用C++函数返回的string类型直接传递进来这样的传递速度比较快booltest( string& szObj, string& szMsg, b原创 2016-09-22 14:23:06 · 754 阅读 · 0 评论 -
lua 的堆栈 与 C++的获取笔录
static int average(lua_State *L){ /* get number of arguments */ int n = lua_gettop(L); double sum = 0; int i; /* loop through each argument */ for (i = 1; i <= n; i++) { /* total the argumen原创 2016-08-21 22:51:50 · 990 阅读 · 0 评论 -
luarocks 库windows 安装使用
LuaSocket这个是Lua扩展库添加的程序,具体可以百度一下,在linux环境中他是比较容易安装和使用的,今天研究了一下在windows安装,发现比较麻烦,所以先记录一下! 这是官方下载地址:https://luarocks.org/modules/luarocks/luasockethttps://luarocks.org/manifests/luarocks/l原创 2016-08-19 00:56:45 · 10882 阅读 · 1 评论 -
cjson 融合lua,暴露全局变量,vs编译
将lua5.1.4源码下来之后导入vs中,然后能够编译为静态库即可,然后下载cjson的源码库,将里面的源码全部导入/* Lua CJSON floating point conversion routines *//* Buffer required to store the largest string representation of a double. * * Lon原创 2016-08-14 11:56:56 · 2528 阅读 · 3 评论