Skip to content

Instantly share code, notes, and snippets.

@ryanlua
Last active December 18, 2025 12:46
Show Gist options
  • Select an option

  • Save ryanlua/17cc8c5aa7934c6746cd1e0d5f06030b to your computer and use it in GitHub Desktop.

Select an option

Save ryanlua/17cc8c5aa7934c6746cd1e0d5f06030b to your computer and use it in GitHub Desktop.
Track memory usage in a memory category over a specified duration.
--!strict
local Stats = game:GetService("Stats")
local TRACK_DURATION: number = 60
local MEMORY_CATEGORY: Enum.DeveloperMemoryTag = Enum.DeveloperMemoryTag.LuaHeap
local CHECKPOINTS: {number} = {0, 10, 25, 50, 75, 90, 100}
print("Starting", MEMORY_CATEGORY, "memory tracking for", TRACK_DURATION, "seconds")
for _, percentage in CHECKPOINTS do
local delayTime = (percentage / 100) * TRACK_DURATION
task.delay(delayTime, function(): ()
local memoryUsage = Stats:GetMemoryUsageMbForTag(MEMORY_CATEGORY)
local totalMemory = Stats:GetTotalMemoryUsageMb()
print(string.format("[%d%%] Memory Usage: %.2f MB | Total Memory: %.2f MB", percentage, memoryUsage, totalMemory))
end)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment