Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Test for https://github.com/multitheftauto/mtasa-blue/commit/5a62615031ab634de9ebae5ceb11afc661ad3525
- -- You can place this script in a "client.lua" file and set it as shared.
- server = not triggerServerEvent
- filename = server and "client.lua" or "testfile2.txt"
- if not server then
- addEventHandler("onClientResourceStart", resourceRoot, function()
- if not File.exists("testfile2.txt") then
- File.new("testfile2.txt"):close()
- end
- end)
- end
- addCommandHandler("test" .. (server and "server" or "client"), function()
- outputDebugString("start test 1")
- file = File(filename)
- file:close()
- file = nil
- outputDebugString("dereferenced closed file. collecting garbage...")
- collectgarbage()
- outputDebugString("finish test 1")
- outputDebugString("start test 2")
- file = File(filename)
- file = nil
- outputDebugString("dereferenced open file. collecting garbage...")
- collectgarbage()
- outputDebugString("finish test 2")
- outputDebugString("start test 3")
- file = File(filename)
- file = nil
- outputDebugString("dereferenced open file. NOT collecting garbage... use /trygarbage. use /forcecollect to clean up.")
- end)
- addCommandHandler("trygarbage", function()
- local f
- for i=1, 13337 do
- f = function()
- f = function()
- return i
- end
- end
- f = f()
- end
- end)
- addCommandHandler("forcecollect", function() collectgarbage() end)
Advertisement
Add Comment
Please, Sign In to add comment