Key-value pair size in kb

For 1kb data limit, how many key-value data pairs can be stored?

e.g. "key"->"value" assume max length of key is 25 chars and value is 100 chars.

You can store up to 1000 chars (1000 bytes = 1kb).

With what you said in your post, you can store up to 10 keys, having 100 chars per value.

Thanks for quick response!
But what about the table size itself which will store these key values e.g. if any key is added, the index on that key will take space also.

An empty table is 64 bytes, and every entry is 16 bytes. (Referenced off this.)

If I do a bit of math, I get this equation:
(1000 - 64)/(16 + data), where data is the size per entry.
The most entries you can get is 55 entries, where each is one char (one byte).

local Game = game
local HttpService = Game:GetService("HttpService")

local function GetTableMemory(Table)
	local Success, Result = pcall(function() return HttpService:JSONEncode(Table) end)
	if not Success then warn(Result) return end
	return utf8.len(Result)
end

local TableMemory = GetTableMemory({a = 1, b = 2, c = 3})
print(TableMemory) --19 (bytes).
1 Like