citizenfx / fivem

The source code for the Cfx.re modification frameworks, such as FiveM, RedM and LibertyM, as well as FXServer.
https://cfx.re/
3.52k stars 2.07k forks source link

Server crash when trying to create 100k objects (server setter) #2607

Open ahcenezdh opened 3 months ago

ahcenezdh commented 3 months ago

What happened?

When creating 100k objects on the server side the server is crashing

Expected result

Not crashing

Reproduction steps

local coords = vec3(148.85, -1393.22, 29.29) -- put coords here
local count = 0
for i = 1, 1000000 do
    local t = CreateObjectNoOffset(`sum_ac_prop_container_01a`, coords.x, coords.y, coords.z, true, true)
    print(t)
    if (t ~= nil) then
     count += 1
    end
end
print(count)

Importancy

Crash

Area(s)

FXServer

Specific version(s)

FiveM

Additional information

No response

outsider31000 commented 3 months ago

Can you post the crash dump? Also 10k networked objects? Just why? Maybe because you hit the limit ?

AvarianKnight commented 3 months ago

100_000 that does not look like 10k to me...

ahcenezdh commented 3 months ago

100_000 that does not look like 10k to me...

My bad

ahcenezdh commented 3 months ago

Can you post the crash dump? Also 10k networked objects? Just why? Maybe because you hit the limit ?

I was trying to found this limit but the server crashed, and even if a limit exist, the server shouln't crash

tens0rfl0w commented 3 months ago

I would argue that a server 'crash'/main thread hang is expected when running a blocking loop with 10k+ iterations, this has nothing to do with the native/object creation itself.

But even when applying reasonable pause times, a count of 100k+ networked objects is not reasonable at all and should never happen in the first place, as you will run into other limitations way earlier.