(svn r15330) -Fix [FS#2597]: leaking of Squirrel when using circular references (by enabling the GC).

This commit is contained in:
rubidium
2009-02-03 22:42:42 +00:00
parent e628c5360d
commit 2eebb52592
10 changed files with 44 additions and 17 deletions

View File

@@ -3,6 +3,7 @@
/** @file ai_core.cpp Implementation of AI. */
#include "../stdafx.h"
#include "../core/bitmath_func.hpp"
#include "../company_base.h"
#include "../company_func.h"
#include "../debug.h"
@@ -68,6 +69,13 @@
}
}
/* Occasionally collect garbage; every 255 ticks do one company.
* Effectively collecting garbage once every two months per AI. */
if ((AI::frame_counter & 255) == 0) {
CompanyID cid = (CompanyID)GB(AI::frame_counter, 8, 4);
if (IsValidCompanyID(cid) && !IsHumanCompany(cid)) GetCompany(cid)->ai_instance->CollectGarbage();
}
_current_company = OWNER_NONE;
}