SpacetimeDB icon indicating copy to clipboard operation
SpacetimeDB copied to clipboard

Memory (RAM) usage keeps increasing

Open NicolasVidal opened this issue 8 months ago • 2 comments

Hey there, I tried toying (rust server and rust CLI client) with the standalone server locally on a toy simulation with ~50 clients randomly moving their avatar on a 16x16 grid each 50ms with simple collision handled on the server. I must say everything was really easy to setup and the macros+codegen works like a charm... But :

the RAM usage of the Spacetime db standalone process just keep increasing ... Like from ~30Mos at start up to 1Go until I killed the whole simulation.

What is taking all this memory ? No further rows are inserted after the clients are connected, they just keep calling reducers to update their positions.

Is this the Undo/Replay history thing that is storing all the events ? Is there a way to disable this behaviour or to limit ram usage ?

Thanks in advance :)

NicolasVidal avatar Apr 15 '25 16:04 NicolasVidal

Hello, we actually have discovered + fixed a memory leak in SpacetimeDB that might have been causing this. The release should be available soon so if you try again tomorrow after a spacetime version upgrade then this issue should be fixed :)

Give it a try and let us know how it goes. Again, it will be out sometime within the next 12 hours or so.

jdetter avatar Apr 15 '25 20:04 jdetter

Thank you very much for your quick answer, I will give it a try as soon as it is released :)

NicolasVidal avatar Apr 15 '25 20:04 NicolasVidal

I confirm that the memory leak is no longer present in 1.1.0 :) \o/ I'm stress-testing with around a hundred simultaneous clients spamming intents every 50ms. The server process is at 44MB (it started at ~33MB with no clients, ~100KB of RAM is used per connected client that spams. And it drops back down to ~33MB when the clients disconnect.

Thank you very much for your awesome work :)

NicolasVidal avatar Apr 16 '25 08:04 NicolasVidal