Hello,
Recently I’ve had to deal with memory constraints with tables for storing data efficiently. So here is what you should do.
The method works in both client and server. It consists of encoding to a json string, and then using buffer to get the precise byte size:
local httpService = game:GetService("HttpService")
-- example table (must be encoded into json later on)
local tableExample = {"c21", "9v9", "v8", "c", "ezeae"}
local encodedJson = httpService:JSONEncode(tableExample)
-- size in bytes
local size = #encodedJson
The result:
(30 bytes)
And when testing on another tool, the result is accurate (30 B).
This method can be useful for API or Datastore requests, so use it as you need, as it has low overhead too.
Now this is a pretty short resource and tutorial, so please let me know if you have feedback.