Hey. I am wondering how I might detect RAM spikes in my game.
Ideas?
Thanks!
you can check the client memory which determines the laginess of your game by holding ctrl + shift + f7 and look on the top left of your screen for your client memory. You can also use the Micro Profiler to determine whether something is making your game laggy.
Thanks for your speedy response.
But how might I detect this using a local script?
You don’t really detect stuff like this with local scripts. You just use the micro profiler or ctrl + shift + f7 in the roblox client to see your local memory.
Yeah, but this would be for an anti-cheat. So that wouldn’t really work.
Yea its not a good idea for an anti-cheat
you can use Stats:GetTotalMemoryUsageMb() to get the server or clients memory usage.
game.Players.PlayerAdded:Connect(function(player)
while true do
wait(5)
if game:GetService("Stats"):GetTotalMemoryUsageMb() > 700 then
print("Player is exploiting",player.Name)
player:Kick("Message here ig")
end
end
end)
you can instead do
game.Players.PlayerAdded:Connect(function(player)
while task.wait(5) do
if game:GetService("Stats"):GetTotalMemoryUsageMb() > 700 then
print("Player is exploiting",player.Name)
player:Kick("Message here ig")
end
end
end)
U need to test the memory usage in roblox not in roblox studio cause there is a big difference, also this anti-cheat is a big mistake since it could kick non exploiters. Since loops take alot of memory ur better off making a exploit that doesnt need this
Im kina out of options at this point
@neviquatro @betterthenharrybarry
If I am not mistaken, those will check for the total Memory Usage, which means it doesn’t detect spikes. So eventually every player will get kicked because it is collective.
Wouldn’t that just kick them if their computer is constantly using more than 700 MB of RAM???
You can just change the value lmaoo
Yeah, I know that I’m just saying that’s not the best solution to the problem.
U can check if it spikes by comparing the values, not that hard.
What might work as a solution is this:
local Stats = game:GetService("Stats")
local RunService = game:GetService("RunService")
local MaxDelta = 100
local LastValue
RunService.Heartbeat:Connect(function()
local CurrentValue = Stats:GetTotalMemoryUsageMb()
if not LastValue then
LastValue = CurrentValue
return
end
local Delta = CurrentValue - LastValue
if Delta >= MaxDelta then
warn("RAM Spiked")
end
LastValue = CurrentValue
end)
Hope it helps
I am going to test it. Ill let you know!
Update: Didnt work