Search code examples
memoryluaprofilingtorch

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


I am a beginner to lua. I am trying to profile the memory usage of my application. When I call collectgarbage('count') repeatedly from lua REPL, the value returned keeps on increasing.

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]

Is there any specific reason for this?


Solution

  • Thanks to @nicol Bolas and @egor skriptunoff said above,

    This is because compiling a lua code allocates memory and also due to string conversion.