Datasize of a table

I was wondering if it is possible to tell how much computer storage a variable takes. I was reading and I found some solutions that said you can use http service to json encode it, but this just seems to return a number that is two more then the amount of characters. And it also makes no sense that that would represent a data amount. So is this possible in roblox? Here is an example of what I want to do:

local table = {1,2,3,4,"5123wdsawdadwad",true,false,2e9}
--Then i would like to find how much storage this is taking up and print it

I’ve never come across any way to do this in ROBLOX, though if you are able to find out what each datatype takes in bytes, you could possibly write a function to loop over the table and increment a “memory in bytes” counter, though this would require you to be able to find out in one way or another what each datatype in ROBLOX takes up.
If you’re wanting to go down that road, this article may benefit you, if indeed it’s still accurate:

I’ve also seen datatypes take up different amounts of memory dependent on the OS platform when writing in C++(the language ROBLOX is written in on the backend), though this may be an incorrect statement in ROBLOX for one reason or another.

1 Like