Place Manager

by Cameron Albert 30. January 2008 17:19

In my previous post Memory Management I was talking about storing character and room data in server memory.

For the Character memory management I basically just use a DateTime value that gets updated each time a request is made by the connected player. If the DateTime exceeds a certain limit such as 20 minutes then the character data is saved and removed from memory. If the player just has a long pause between requests their character data will be reloaded if they make another request after the cleanup.

For the Room or Place data I've though about doing the same thing, just store a DateTime value and update it whenever a player performs an action in the room. I am not sure this is the best approach since the only commands that reference the Place object are movement, looking, some inventory and buying commands. Other actions such as casting spells, viewing stats, private chat, etc. do not reference the Place object. Of course, I guess if you are not accessing the Place object no need to have it in memory but once a player attempts to move again I would need to reload the Place. I might just maintain a list in the Place object of all the players currently located there and only remove the object once those references have been removed. I'll try a few things and record what I find.

Tags: , ,

Game Development | Perenthia PBBG

Comments

1/31/2008 1:01:32 PM #

idiotcoder

I'd consider having a property on the character that exposes a reference to their current location.

Every x minutes, run through the list of active players (those you still have in memory) and any places that aren't in that list can safely be removed.  It does make for spiky memory management, but with some tweaking, it can be a fairly reliable way to keep an eye on it.

idiotcoder United States

1/31/2008 1:18:23 PM #

calbert

That is a good idea, I already have a reference to the Place on the Player object. I am also building some tools so that I can monitor the objects in memory from the admin side of the aplication. I can already view players but am going to setup to monitor places and log the heartbeat iterations.

calbert United States

Powered by BlogEngine.NET 1.5.0.7
Modified Theme by Mads Kristensen

About the Author

CameronAlbert.com I am Senior Software Development Consultant specializing in Silverlight, WPF and the Microsoft .NET Framework. 

I have released an iPhone game called the Adventures of Puppyman that was built using ExEn and am currently working on a WP7 and iPhone version of Perenthia soon to be released.

View Cameron Albert's profile on LinkedIn
See how we're connected

Follow cameronalbert on Twitter

 

Recommended Books

Silverlight 4 Business Application Development - Beginner's Guide:

http://www.packtpub.com/microsoft-silverlight-4-business-application-development-beginners-guide/book

Microsoft Silverlight 4 Business Application Development: Beginner’s Guide