我是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代码会分配内存,也归因于字符串转换。

关于memory - 调用collectgarbage('count')增加lua中的内存使用量,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/38314219/

10-12 23:12