Advertisement
Guest User

test 3

a guest
Jan 26th, 2020
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.26 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. --// Config
  9.  
  10. local iterations = 10000
  11. local chunkSize = 1000
  12.  
  13. local yield = 0.03
  14.  
  15. --// Events
  16.  
  17. local heartbeat = runService.Heartbeat
  18.  
  19. -- [[ Function Declarations ]] --
  20.  
  21. local function printMemory(header)
  22.     print(header, stats:GetTotalMemoryUsageMb())
  23.    
  24.     local enums = Enum.DeveloperMemoryTag:GetEnumItems()
  25.    
  26.     for i, enum in pairs(enums) do
  27.         warn(enum.Name, " = ", stats:GetMemoryUsageMbForTag(enum))
  28.     end
  29. end
  30.  
  31. -- [[ Init ]] --
  32.  
  33. do
  34.     --// Test Memory Over Time
  35.    
  36.     wait(2)
  37.    
  38.     printMemory("Initial: ")
  39.    
  40.     for i = 1, iterations / chunkSize do
  41.         for i = 1, chunkSize do
  42.             local newPart = Instance.new("Part")
  43.            
  44.             newPart.Anchored = true
  45.             newPart.Parent = workspace
  46.         end
  47.        
  48.         heartbeat:Wait()
  49.     end
  50.    
  51.     printMemory("After Part Creation: ")
  52.    
  53.     local a = workspace:GetChildren()
  54.    
  55.     for i, part in pairs(a) do
  56.         if part.Name == "Part" then
  57.             part:Destroy()
  58.         end
  59.     end
  60.    
  61.     a = nil
  62.    
  63.     printMemory("After Destroying Parts:")
  64.    
  65.     wait(1)
  66.    
  67.     printMemory("Verify garbgecollection cycle has passed:")
  68.     wait(5)
  69.     printMemory("Verify garbgecollection cycle has passed 2:")
  70. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement