Last active
December 18, 2025 12:46
-
-
Save ryanlua/17cc8c5aa7934c6746cd1e0d5f06030b to your computer and use it in GitHub Desktop.
Track memory usage in a memory category over a specified duration.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --!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