collectgarbage()gccollect()garbageCollect()collectMemory()collectstatus()collectinfo()collectgarbage("count")gcstatus()collectgarbage("collect")collectgarbage("stop")collectgarbage("pause")collectgarbage("maxheap", size)collectgarbage("setheap", size)collectgarbage("setmax", size)collectgarbage("setpause", size)collectgarbage("setpause", value) do?
debug.trace()debug.profile()debug.getinfo()os.time()os.clock() in Lua performance profiling?
require function in performance optimization?
debug library in Lua?
collectgarbage() frequentlycollectgarbage()table.insert within a looptable.remove for large tables..) in Lua?
collectgarbage() before each recursion| Qno | Answer |
|---|---|
| 1 | A) Free memory for unused variables |
| 2 | A) collectgarbage() |
| 3 | B) It runs periodically based on memory usage |
| 4 | C) Mark and sweep |
| 5 | C) collectgarbage("count") |
| 6 | A) Memory leaks may occur |
| 7 | A) Call collectgarbage("collect") |
| 8 | A) collectgarbage("maxheap", size) |
| 9 | A) Sets how often the garbage collector will run |
| 10 | A) It may cause performance issues due to unpredictability |
| 11 | B) To measure and improve the performance of code |
| 12 | C) debug.getinfo() |
| 13 | C) Measures CPU time used by the script |
| 14 | A) To load libraries only when necessary |
| 15 | B) Using tables to store data efficiently |
| 16 | A) LuaProf |
| 17 | B) To profile and inspect code execution |
| 18 | B) Avoid creating new objects during execution |
| 19 | A) Tables increase memory usage due to garbage collection overhead |
| 20 | B) Avoiding complex loops and recursion |
| 21 | A) Excessive use of memory due to table copying |
| 22 | A) Allocating and deallocating memory frequently |
| 23 | A) They can slow down the execution speed due to lookup time |
| 24 | C) Pre-allocating the table with a fixed size when possible |
| 25 | B) Reuse tables outside of the loop |
| 26 | A) It uses excessive CPU time when concatenating large strings |
| 27 | C) Pre-allocate table size or use table size hints |
| 28 | A) Not freeing tables from memory after use |
| 29 | B) Convert recursion into an iterative solution |
| 30 | A) Profile the script first, then address performance issues |