How to read resmon properly
The number that matters most is the one a resource costs while nothing is happening.
resmon is the FiveM resource monitor: type resmon true in the F8 console and it lists the CPU time and memory each resource uses on your client. Read the CPU column while nothing is happening first; on Freedom Roleplay every resource targets 0.00 ms idle and at most 0.10 ms while it is in use.
Those two numbers are a target I hold my own scripts to, not a law of FiveM. The patterns further down are what usually stands between a resource and that target.
What the numbers mean
The CPU column is in milliseconds, and on the client a script that waits 0 runs on every frame. At 60 frames per second a frame lasts about 16.7 ms, and the game needs its share of that. A resource that keeps 0.5 ms busy on every frame takes about 3% of the budget, on every player's machine, all the time.
The resmon in F8 shows the client side: what each resource costs the player who opened it. Server hitches are a separate question, with a separate tool further down.
Idle first, then active
Idle means standing somewhere quiet with nothing open. A resource that costs time there is running a loop it does not need, and it will still be running it at peak, on top of everything else. That is the first column to read and the first thing to fix.
Active means while you use the thing: the menu is open, the job step is running, you are driving past the camera. A short rise there is normal. What matters is that it drops back to 0.00 when you stop. If it does not, something was never cleaned up: a thread that kept running after the menu closed, a hidden NUI page that is still animating, a zone or prop nobody removed.
Measure so the number means something
- Measure on a busy server, not an empty one. Some costs only show up with players and entities around.
- Write down the idle number before you touch anything. Then use the feature, stop, wait a few seconds and read it again.
- Check from more than one place. A resource that only matters near one location should cost nothing on the other side of the map.
- Change one thing at a time and keep the before and after. A fix that does not move the number was not the fix.
- For the server, use the profiler: profiler record 500 in the server console, then profiler view. It shows which resource, and which line, took the time during a hitch.
What usually breaks the targets
- A Wait(0) loop that checks a distance or a key on every frame, everywhere on the map. Per-frame work belongs only to the moment it is needed and the place it happens; the rest can wait 250 ms to a second, or not run at all until an event says so.
- Markers and 3D text drawn by a permanent thread for every location at once, instead of only for the one you are standing at.
- One thread per entity, or a scan over every ped or vehicle in the pool, where one bounded manager would do.
- A NUI page that sends messages or updates the DOM on a timer instead of when something changes, or keeps running while it is hidden.
- Models, animations and effects requested every tick or preloaded all at once, and never released afterwards.
- Images and other assets sent through events instead of shipped as files in the resource. Network traffic is performance too.
Event-driven, in plain terms
Most of those have the same fix: do the work when something happens, not on every frame in case it did. In practice that means ox_lib points and zones that wake a resource when a player comes close and put it back to sleep when he leaves, lib.onCache to react when the player's vehicle or weapon changes instead of polling for it, and state bag handlers to hear about server state instead of asking for it.
The rule behind it on Freedom is three things: event-driven logic, work bounded to where it is needed, and complete cleanup on every exit and on resource stop. Threads, zones, props, cameras and blips go away when they are done, so a restart leaves nothing behind.
When a resource misses them
If the source is readable, it can be fixed. Find the loop with the profiler, move the work to an event or a zone, and measure again the same way. If the resource is escrowed, nobody but the author can open it, and the honest choices are a support ticket or a replacement.
And if every resource reads fine but the server still stutters at peak, the cause is probably not a script at all. Shared CPU and a remote database both look exactly like one; the guide on why your server lags covers how to tell them apart.
Questions about this
What is a good resmon number?
0.00 ms while nothing is happening, and 0.10 ms or less while a resource is in use. Those are the targets on Freedom Roleplay. A resource that costs time at idle runs a loop it does not need, and keeps running it at peak.
Does resmon show server lag?
No. The resmon in the F8 console shows what each resource costs on your own client. For server hitches, record the server with the profiler (profiler record 500, then profiler view) and look at which resource and which line took the time.
Is resmon on an empty server useful?
Only as a first look. Anything that costs time on an empty server costs at least as much at peak, so it shows the worst loops. Problems that grow with players and entities only show up on a busy server, so measure there before calling a resource fine.
Want this handled instead of researched?