lua垃圾收集器的调试输出的最佳方法是什么? [英] What is the best way for debug output for the lua garbage collector?

查看:69
本文介绍了lua垃圾收集器的调试输出的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要lua中的游戏状态对象(不是c ++或未绑定到c ++),以管理我的C ++引擎中的灯光,摄像机,对象和事件(lua对象是与c ++分离的实体,很漂亮只是标准的lua表).我担心GC将如何删除这些对象,因为它们将被动态创建和删除.为GC打开输出的最佳方法是什么?我的代码中嵌入了lua源代码...

I need a game state object in lua(not c++ or tied to C++) to manage lights, cameras, objects, events from my C++ engine (the lua objects are seperate entities from c++, pretty much just standard lua tables). I am concerned about how the GC is going to act in removing these objects since they are going to be created and removed on the fly. what is the best way to turn on Output for the GC? I have the lua source embedded in my code...

推荐答案

Lua垃圾收集器没有任何输出.您有两个选择.

The Lua garbage collector doesn't have any output. You have two choices here.

首先,您可以为Lua提供一个自定义分配器.这将使您跟踪Lua分配内存的方式和时间.这将说明GC多久请求一次更多的内存,以及多久释放一次所述内存.您还可以添加分配跟踪,使您可以在应用程序退出时检测泄漏"的内存.

First, you could provide Lua a custom allocator. This would let you track how and when Lua allocates and deallocates memory. This would tell how how often the GC asked for more memory and how often it frees said memory. You could also add allocation tracking that would let you detect 'leaked' memory at application exit.

由于拥有源代码,因此您也可以直接将工具添加到Lua垃圾收集器代码中.它包含在lugc.c中.

Since you have the source, you could also add instrumentation to the Lua garbage collector code directly. It's self contained in lugc.c.

这篇关于lua垃圾收集器的调试输出的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆