I’d really like the script performance tab to show individual script memory usage if possible, since I constantly run into the notorious “not enough memory” -error but I have over 200 modules/scripts so It’s practically impossible to find the root cause of it.
(no it’s not my hardware I have 16 gigabytes of memory, 3 gigabytes of video memory)
local scripts = {}
local function rec(o)
for k,v in pairs(o:GetChildren()) do
if v.ClassName == "Script" then
table.insert(scripts,v)
v.Disabled = true
end rec(v)
end
end rec(workspace)
rec(game:GetService("ServerScriptService"))
local start = gcinfo()
for k,v in pairs(scripts) do
v.Disabled = false wait(1)
local dif = gcinfo()-start
func = dif > 1000 and warn or print
func(v:GetFullName(),"=",dif)
start = gcinfo()
end print("We're done, folks!")
Of course untested, but it should work (in theory).
Just do Start Server (or even online) and run the code.
(If you do it online, you should probably use F9)
(If you do it in a script, big chance it disables itself)
Well I’m running out of memory on the client, and I tried to put that as a localscript and set rec(game.Players.LocalPlayer.PlayerGui) since thats where my client code resides, but it prints “Were done here folks” as soon as it loads up, and If I try to put that in the command bar after memory has run out I cant because roblox has crashed
That’s probably because the code disabled and enabled itself…
Just add an extra check:
if v.ClassName == "Script" and v ~= script then
table.insert(scripts,v)
v.Disabled = true
end rec(v)
EDIT:
Uh, all on the same second? Did wait(1) bug out?
EDIT2: Nvm it prints 3x statistics about itself, as it disabled and re-enabled itself.
Add that check I posted a few lines back, or put Diagnostics in Backpack.
(In case you don’t do rec(Backpack), that is)
local scripts = {}
local function rec(o)
for k,v in pairs(o:GetChildren()) do
if v.ClassName == "LocalScript" and v ~= script then
table.insert(scripts,v)
v.Disabled = true
end rec(v)
end
end rec(script.Parent)
local start = gcinfo()
for k,v in pairs(scripts) do
v.Disabled = false wait(1)
local dif = gcinfo()-start
func = dif > 1000 and warn or print
func(v:GetFullName(),"=",dif)
start = gcinfo()
end print("We're done, folks!")
Also TransparencyController is a StarterPlayerScript(by Roblox) and I don’t believe I even use that behaviour in StarterPlayer, I believe it’s just the first script to realize there’s not enough memory
Well, reviewing those results, it doesn’t happen soon after the scripts run.
Only thing that you can do is enable them 5 by 5 or so.
If memory still runs out, then check the left over 5 one by one.
Run some code in the command bar that crawls through the source code of all of the scripts/modules/etc, and use complexity analysis to find bits of code that are executed really often and multiply by the number of variables created in each block. Then print those out, sorted by how many variables are created, and you’ll find your memory problem.
There should be an indicator of memory usage in Script Performance, but I assume you want to find the problem now. Unless you want to wait a couple months or longer for memory statistics in Script Performance, you have to find out which of these modules is causing the problem and the best way to do that is automatically.
We can assume it’s probably caused by something that runs (close to) every tick, like RenderStepped.
We also know memory shouldn’t be an issue unless you’re storing data and never clearing it.