调用 collectgarbage('count') 会增加 lua 中的内存使用

call to collectgarbage('count') increases memory usage in lua

我是 lua 的初学者。我正在尝试分析我的应用程序的内存使用情况。当我从 lua REPL 重复调用 collectgarbage('count') 时,返回的值不断增加。

th> collectgarbage()
0
                                                                      [0.0018s]
th> collectgarbage('count')
856.8408203125
                                                                      [0.0001s]
th> collectgarbage('count')
858.669921875
                                                                      [0.0001s]
th> collectgarbage('count')
860.345703125
                                                                      [0.0000s]
th> collectgarbage('count')
862.171875
                                                                      [0.0000s]

这有什么具体原因吗?

感谢上面所说的@nicol Bolas 和@egor skriptunoff,

这是因为编译lua代码会分配内存,也是由于字符串转换。