Spodii / netgore

Cross platform online rpg engine using C# and SFML
http://www.netgore.com/
40 stars 16 forks source link

ItemEntity in server creates excessive garbage #246

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
When moving an ItemEntity around places, namely to/from the inventory, 
excessive garbage seems to be created. This would be no problem if it wasn't 
for the fact that this garbage also results in extra hits to the database. The 
primary area of importance is when adding an item into an inventory, which 
seems to create a new object instance even if it was all added.

Original issue reported on code.google.com by Spodiii on 30 Oct 2010 at 1:41

GoogleCodeExporter commented 9 years ago
This was fixed quite a few revisions ago - just forgot to update the issue.

The fix involved:
1. Adding a IsPersistent flag to items to help reduce database garbage 
significantly.
2. Adding items to the inventory worked like it should have in the first place 
- add the actual object and not an implicitly created deep copy.
3. Make adding to inventory only create a new instance if needed.

Original comment by Spodiii on 18 Nov 2010 at 7:20