Talk:NPC Lag Compensation

From Valve Developer Community
Revision as of 22:32, 14 November 2009 by Winston (talk | contribs)

Jump to: navigation, search

I appreciate that this article is messily laid out ... help on that front would be appreciated! Rather than large code blocks, I had initially used the form "select this whole function and find & replace in selection Player, replacing with Entity" ... this got very confusing. --Winston 16:40, 11 Apr 2008 (PDT)

We used this code for Zombie Master, and it appears to contain a memory leak (at the time of writing). I solved it by moving the NPC's lag compensation data (ie. its linked list of LagRecords etc) into BaseNPC. Not very pretty, but it stops leaking memory. I'd theorize that the switching around of tracks performed in UpdateAIIndexes() may be losing track of memory somehow, perhaps only in certain edge cases where many NPCs die. Whatever the cause, having each NPC hold its own lagcompensation data simplifies things a lot and prevents the leak from occurring.

I don't feel I have sufficient information on the cause of the leak to modify this article, and the solution I described isn't ideal, but I figured I'd at least leave a note for people who run into a similar problem. --theGreenBunny 01:12, 13 Dec 2008 (PST)

Aha, I was experiencing a significant leak too, but I'd never suspected this code. Eitehr what you describe, or perhaps some of the Purge calls need to be changed to PurgeAndDeleteContents. I hope to be able to get back to this sometime in the next few weeks. --Winston 12:55, 20 Dec 2008 (PST)
Ok, it's been most of a year. I've now tried to merge the required changes into this article, based on code that has been further modified. There may be errors or inconsistancies, so if you try this, please post here. --Winston 22:32, 14 November 2009 (UTC)