If you’re an existing StudioCLI user, you probably know that the package manager is extremely laggy when installing, uninstalling, and updating packages.
Here’s the important bit of code for installing a package (full source here):
-- packageName is either a number or a string
-- that eventually becomes a number
-----------------------------------------------
local packageName = regular[1]
if tonumber(packageName) then -- if it's a number ID
--local latestVersion = SERVICES.InsertService:GetLatestAssetVersionAsync(tonumber(packageName))
--local module = SERVICES.InsertService:LoadAssetVersion(latestVersion):GetChildren()[1]
local objects = game:GetObjects("rbxassetid://"..tostring(packageName))
local module = objects[1]
if table.find(flags, "g") or args['global'] then
if module then
if not game.ReplicatedStorage:FindFirstChild("rbx_modules") then
local rbx_modules = Instance.new("Folder", game.ReplicatedStorage)
rbx_modules.Name = "rbx_modules"
end
module.Parent = game.ReplicatedStorage:FindFirstChild("rbx_modules")
module:SetAttribute("rbx_package_ID", packageName)
end
elseif table.find(flags, "d") or args['dev'] then
if module then
module.Parent = self.UI.DEV_MODULES
module:SetAttribute("rbx_package_ID", packageName)
end
else
if module then
module.Parent = self.PATH
module:SetAttribute("rbx_package_ID", packageName)
end
end
objects = nil -- Was this the memory leak?
else -- if its a string name that should become an ID
if REGISTRY[tostring(packageName):upper()] then
--local latestVersion = SERVICES.InsertService:GetLatestAssetVersionAsync(REGISTRY[tostring(packageName):upper()])
--local module = SERVICES.InsertService:LoadAssetVersion(latestVersion):GetChildren()[1]
local objects = game:GetObjects("rbxassetid://"..tostring(REGISTRY[tostring(packageName):upper()]))
local module = objects[1]
if table.find(flags, "g") or args['global'] then
if module then
if not game.ReplicatedStorage:FindFirstChild("rbx_modules") then
local rbx_modules = Instance.new("Folder", game.ReplicatedStorage)
rbx_modules.Name = "rbx_modules"
end
module.Parent = game.ReplicatedStorage:FindFirstChild("rbx_modules")
module:SetAttribute("rbx_package_ID", packageName)
end
elseif table.find(flags, "d") or args['dev'] then
if module then
module.Parent = self.UI.DEV_MODULES
module:SetAttribute("rbx_package_ID", packageName)
end
else
if module then
module.Parent = self.PATH
module:SetAttribute("rbx_package_ID", packageName)
end
end
objects = nil -- Was this the memory leak?
end
end
I believe the culprit is game:GetObjects()
, but still haven’t been able to figure it out.
Thoughts on how to fix this?