lua垃圾收集器的调试输出的最佳方法是什么?

编程入门 行业动态 更新时间:2024-10-12 08:24:03
本文介绍了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垃圾收集器的调试输出的最佳方法是什么?

本文发布于:2023-11-07 10:29:29,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1566214.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:垃圾   方法   收集器   lua

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!