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 ]] --
- --// Config
- local iterations = 10000
- local chunkSize = 1000
- local yield = 0.03
- --// Events
- local heartbeat = runService.Heartbeat
- -- [[ Function Declarations ]] --
- local function printMemory(header)
- print(header, stats:GetTotalMemoryUsageMb())
- local enums = Enum.DeveloperMemoryTag:GetEnumItems()
- for i, enum in pairs(enums) do
- warn(enum.Name, " = ", stats:GetMemoryUsageMbForTag(enum))
- end
- end
- -- [[ Init ]] --
- do
- --// Test Memory Over Time
- wait(2)
- printMemory("Initial: ")
- for i = 1, iterations / chunkSize do
- for i = 1, chunkSize do
- local newPart = Instance.new("Part")
- newPart.Anchored = true
- newPart.Parent = workspace
- end
- heartbeat:Wait()
- end
- printMemory("After Part Creation: ")
- local a = workspace:GetChildren()
- for i, part in pairs(a) do
- if part.Name == "Part" then
- part:Destroy()
- end
- end
- a = nil
- printMemory("After Destroying Parts:")
- wait(1)
- printMemory("Verify garbgecollection cycle has passed:")
- wait(5)
- printMemory("Verify garbgecollection cycle has passed 2:")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement