Hello! ^^
So i wanted to ask if Libraries are a go or no go because of ram usage.
I have created a place with and without a library and made a script that gave me the average ram usage. [i just saved the latest 20 ram usages and calculated the average, and dw, i cleared the not used ones]
So why am i asking this? Someone told me that libraries take more Ram, which is a problem.
I tested the two places and saw, that the difference was maybe only about 5-7MB of Ram. But my game was about 2% finished so yeah, maybe to early to tell.
Lemme show how my library works:
Method of calling:
local library = require(game:GetSerivce("ReplicatedStorage").Library)
What it does? It just requires a library that returns the main framework.
The framework is the main thing.
The framework saves Services that i imported in them so i can do stuff like:
libary.Workspace
library.ReplicatedStorage
etc...
Source Code:
function packServices()
--// Shared
module["Workspace"] = game:GetService("Workspace")
module["Players"] = game:GetService("Players")
module["Lighting"] = game:GetService("Lighting")
module["ReplicatedFirst"] = game:GetService("ReplicatedFirst")
module["ReplicatedStorage"] = game:GetService("ReplicatedStorage")
module["TweenService"] = game:GetService("TweenService")
module["MarketplaceService"] = game:GetService("MarketplaceService")
module["RunService"] = game:GetService("RunService")
module["PhysicsService"] = game:GetService("PhysicsService")
module["CollectionService"] = game:GetService("CollectionService")
if runningSession == "Server" then --// SERVER
module["ServerScriptService"] = game:GetService("ServerScriptService")
module["ServerStorage"] = game:GetService("ServerStorage")
module["DataStoreService"] = game:GetService("DataStoreService")
module["MessagingService"] = game:GetService("MessagingService")
elseif runningSession == "Client" then --// CLIENT
module["LocalPlayer"] = module.Players.LocalPlayer
module["StarterGui"] = game:GetService("StarterGui")
module["UserInputService"] = game:GetService("UserInputService")
module["ContentProvider"] = game:GetService("ContentProvider")
end
end
Also i added functions importing, so i can directly use functions so i dont need to require modules all the time.
Example:
library:Abbreviate(2500) -> "2.5k"
library:warn("Hello!") -> Warns in the output with this text
etc...
Source Code:
function importFunctions(handlerSide)
if handlerSide ~= "Shared" then importFunctions("Shared") end
local getFolder : Folder = getDirectory(handlerSide)
local importedNumber : number = 0
for i,v in pairs(getFolder:GetChildren()) do
if not v:IsA("ModuleScript") then continue end
local createTimer = DateTime.now().UnixTimestampMillis
local requireModule = require(v)
for i2,v2 in pairs(requireModule) do
if string.find(tostring(v2), "function: ") == nil then continue end
importedNumber += 1
module[tostring(i2)] = v2
if debugEnabled then -- yeah ignore this, this is for debugging so i can check how long a module took to load, but i need to change this. I just saw that this doesnt really work 💀
createTable(handlerSide, v.Name, i2, {
imported_number = importedNumber,
loaded_in_ms = createTimer - timeStarted
})
end
end
end
end
So to conclusion: This module is just to save time and lines of code, but is this gonna take a lot of ram in the future?
This is why i made this post to ask if its gonna hurt performance and if i should think of changing this.
Thanks for reading, and have a nice day! ^^