LuaJit 增加堆栈/堆大小

发布于 2024-08-03 07:17:39 字数 52 浏览 5 评论 0原文

我在 LuaJit 中不断收到内存不足错误。如何增加堆栈或堆的大小?

谢谢

I keep getting a out of memory error in LuaJit. How do I increase the stack or heap size?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

2024-08-10 07:17:39

除了玩具示例之外,我自己还没有使用过 LuaJIT。但由于还没有其他人提供任何答案...

从浏览 文档 来看,LuaJIT 依赖于 Coco标准协程库的扩展。 Coco 引入的更改之一是创建新协程的函数现在采用指定堆栈大小的可选参数。

引用 Coco 文档:

coro = coroutine.create(f [, cstacksize])
func = coroutine.wrap(f [, cstacksize])

可选参数cstacksize
指定 C 堆栈的大小
为协程分配:

  • 如果未给出cstacksize或者为nil,则使用默认堆栈大小
    零。
  • 如果 cstacksize-1,则不会分配 C 堆栈。
  • 任何其他值都会向上舍入到最小大小(即使用 1 来获取
    最小尺寸)。

还有新函数 coroutine.cstacksize([newdefault]) 用于设置默认的 C 堆栈大小,以及对 C API 的一些相应更改。

此外,LuaJIT 版本的 luaconf.h 中有许多编译时配置选项。那里可能有一些设置默认值的东西。在 Windows 上,可执行文件的基本堆栈还有一个链接时设置,由 MSVC 的 LINK.EXE 通过应用程序的 .DEF 文件中的 STACKSIZE 语句进行设置。

I haven't used LuaJIT myself, other than with toy examples. But since noone else has provided any answers yet...

From skimming the documentation, LuaJIT depends on the Coco extensions to the standard coroutine library. One of the changes introduced by Coco is that the functions that create a new coroutine now take an optional argument that specifies the stack size.

Quoting the Coco docs:

coro = coroutine.create(f [, cstacksize])
func = coroutine.wrap(f [, cstacksize])

The optional argument cstacksize
specifies the size of the C stack to
allocate for the coroutine:

  • A default stack size is used if cstacksize is not given or is nil or
    zero.
  • No C stack is allocated if cstacksize is -1.
  • Any other value is rounded up to the minimum size (i.e. use 1 to get
    the minimum size).

There is also the new function coroutine.cstacksize([newdefault]) that sets the default C stack size, as well as some corresponding changes to the C API.

Furthermore, there are numerous compile-time configuration options in the LuaJIT version of luaconf.h. There may be something in there that sets the default. On Windows, there is also a link-time setting for the executable's basic stack, set by MSVC's LINK.EXE via the STACKSIZE statement in the application's .DEF file.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文