How much memory will a big module storing data script take up?

Not sure if this is the best category for this topic, but it felt the most correct.

Anyways I have a module script that stores data for my game.

["Visage Relic"] = {
		Image = "0",
		Type = "SEASONAL",
		Season = "Summer",
	},
	["Vlad's Coffin"] = {
		Image = "0",
		Type = "SEASONAL",
		Season = "Fall",
	},
	["Voodoo Bone Witch"] = {
		Image = "0",
		Type = "REGULAR"
	},

It’s practically 2,000 lines of just this. It got me thinking though that I should start serializing, because a table like this has to take up some memory right?

["Visage Relic"] = {
		I = "0",
		T = "S",
		S = "S",
	},
	["Vlad's Coffin"] = {
		I = "0",
		T= "S",
		S= "F",
	},
	["Voodoo Bone Witch"] = {
		I = "0",
		T = "R"
	},

Would converting the whole table to something like above help with memory? Or should I not even bother?

Compared to other game assets, I don’t think it would take much memory at all. Things like image textures and 3D models take up much more memory in your game. You really shouldn’t ever have to worry about how much memory your code will take, even if it’s just a big list of things.

2 Likes

it compiles 400K lines of Luau code in 0.5 seconds on a single core of a desktop Core i7

Your parts take up a lot more memory

2 Likes

Just to add to the answer, the difference between the two options is also tiny because strings in lua are interned, i.e. in the code

local a = "test"
local b = "test"

Only one copy of the literal "test" is created in memory, and a and b reference the same string in memory.

2 Likes