I'm currently coding a realtime game. I'm doing alot of technical operations with the physics world (resimulations of old world states etc.) to prevent game lag. I save the world state every physics update, so I can re simulate it later if needed.

Of course this consumes alot of memory, so I'm trying to decide after what period will I remove old world states. For example, if a world state is 250 milliseconds old, remove it from memory. Then, if any player movements are received from players, that occurred more than 250 milliseconds old, discard them.

This would theoretically discontinue any physics movements of players with a latency of 250+. This is to improve the performance/experience for other players, and to maintain low memory usage.

My question is, what is a fair latency to cut off players at (for the good of other players)?


It depends on how fast things happen in your game, and what typical latency you expect from your players.

My gut feeling is that 0.25 seconds is too little. World of Tides, a game I worked on that used this approach, stored several seconds worth of history.

Added Also, you most probably do not need to save a snapshot of a whole world for every frame. Save only some key values and interpolate between them - this would save you a lot of memory.


You don't need to save the entire world state, only the things that are relevant to the players. Particles, static actors, shaders etc. is irrelevant. Maybe even animations depending on your game. If only relevant information is stored, it shouldn't take that much memory.

I would recommend saving like a full second of gameplay. Remember to clear old data when you recieve a correction from the server. All data stored before the correction timestamp (not the current time) can be cleared. If it was more than a second the game would be unplayable anyway with the correction happening sooner than the recieved package.

  • \$\begingroup\$ By saving the world state, I meant the physics world state, which is incredibly small. \$\endgroup\$ – liamzebedee Dec 16 '11 at 22:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.