How I could get the size in KB/MB of a table by using GCinfo?
local memoryUsage = gcinfo()
local memoryUsageAfterGC = gcinfo() - memoryUsage
print("Memory usage of the table: " .. memoryUsage .. " KB")
I tried this and yeah it kinda prints an estimated size:
local httpS = game:GetService("HttpService")
local aTable = {
["Imagine"] = {Many = "Stuff", In = "this", Table = "aaa"},
["Imagine2"] = {Many = "Stuff", In = "this", Table = "aaa"}
}
local encode = httpS:JSONEncode(aTable)
local byte = string.len(encode)
local kb = byte / 1024
local mb = kb / 1024
warn(kb,"KB")
warn(mb,"MB")
But how could I do it by using GC? Or any suggestion to get the size of a table?
Thank you for your time, any suggestion is appreciated!
2 Likes
This post I found from another topic may help?
3 Likes
Thank you!
But its the same approach I already did in the script I did show.
I wanna know if its possible to do it by GC
2 Likes
Wigglyaa
(Wigglyaa)
#4
The docs state that the GC is sandboxed to only allow the count operation. So I would say your options are pretty limited.
2 Likes