Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- [[ Service Declarations ]] --
- local stats = game:GetService("Stats")
- local runService = game:GetService("RunService")
- -- [[ Variable Declarations ]] --
- --// Collection
- local instances = {}
- --// Config
- local iterations = 10000
- local chunkSize = 1000
- local yield = 0.03
- --// Events
- local heartbeat = runService.Heartbeat
- print("Initial: ", stats:GetTotalMemoryUsageMb())
- warn(collectgarbage("count"))
- -- [[ Init ]] --
- do
- --// Test Memory Over Time
- for i = 1, iterations / chunkSize do
- for i = 1, chunkSize do
- local newPart = Instance.new("Part")
- newPart.Anchored = true
- instances[#instances + 1] = newPart
- newPart.Parent = workspace
- end
- heartbeat:Wait()
- end
- print("After Part Creation: ", stats:GetTotalMemoryUsageMb())
- warn(collectgarbage("count"))
- for i, part in pairs(instances) do
- part:Destroy()
- instances[i] = nil
- end
- print("After Destroying Parts:", stats:GetTotalMemoryUsageMb())
- warn(collectgarbage("count"))
- wait(1)
- instances = nil
- print("After dereferencing the table: ", stats:GetTotalMemoryUsageMb())
- warn(collectgarbage("count"))
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement