Advertisement
Guest User

test

a guest
Jan 26th, 2020
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.15 KB | None | 0 0
  1. -- [[ Service Declarations ]] --
  2.  
  3. local stats = game:GetService("Stats")
  4. local runService = game:GetService("RunService")
  5.  
  6. -- [[ Variable Declarations ]] --
  7.  
  8. --// Collection
  9.  
  10. local instances = {}
  11.  
  12. --// Config
  13.  
  14. local iterations = 10000
  15. local chunkSize = 1000
  16.  
  17. local yield = 0.03
  18.  
  19. --// Events
  20.  
  21. local heartbeat = runService.Heartbeat
  22.  
  23. print("Initial: ", stats:GetTotalMemoryUsageMb())
  24. warn(collectgarbage("count"))
  25.  
  26. -- [[ Init ]] --
  27.  
  28. do
  29.     --// Test Memory Over Time
  30.    
  31.     for i = 1, iterations / chunkSize do
  32.         for i = 1, chunkSize do
  33.             local newPart = Instance.new("Part")
  34.            
  35.             newPart.Anchored = true
  36.            
  37.             instances[#instances + 1] = newPart
  38.             newPart.Parent = workspace
  39.         end
  40.        
  41.         heartbeat:Wait()
  42.     end
  43.    
  44.     print("After Part Creation: ", stats:GetTotalMemoryUsageMb())
  45.     warn(collectgarbage("count"))
  46.    
  47.     for i, part in pairs(instances) do
  48.         part:Destroy()
  49.         instances[i] = nil
  50.     end
  51.    
  52.     print("After Destroying Parts:", stats:GetTotalMemoryUsageMb())
  53.     warn(collectgarbage("count"))
  54.    
  55.     wait(1)
  56.     instances = nil
  57.     print("After dereferencing the table: ", stats:GetTotalMemoryUsageMb())
  58.     warn(collectgarbage("count"))
  59. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement