summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2014-02-06 20:55:49 +0000
committerrubidium <rubidium@openttd.org>2014-02-06 20:55:49 +0000
commitfcb122124b042d343f38abe547e83f78ef848359 (patch)
tree71b5c07f4bce5b002d37869160f26f93cb05f284
parentf99d3805834f4999056eb4967aa89a634d7a8134 (diff)
downloadopenttd-fcb122124b042d343f38abe547e83f78ef848359.tar.xz
(svn r26310) -Codechange: clean up some caches during town generation to keep memory usage significantly lower (MJP)
-rw-r--r--src/town_cmd.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp
index d9843866c..13616a2cc 100644
--- a/src/town_cmd.cpp
+++ b/src/town_cmd.cpp
@@ -46,6 +46,7 @@
#include "object_base.h"
#include "ai/ai.hpp"
#include "game/game.hpp"
+#include "gfx_layout.h"
#include "table/strings.h"
#include "table/town_land.h"
@@ -1889,6 +1890,14 @@ bool GenerateTowns(TownLayout layout)
* Note that this is really a suggested value, not a required one.
* We would not like the system to lock up just because the user wanted 100 cities on a 64*64 map, would we? */
do {
+ if (total % 512 == 0) {
+ /* Clear the caches regularly, otherwise it will only be done
+ * at the end of the whole cycle when OpenTTD has allocated
+ * lots and lots of memory for these essentially caches. */
+ ClearPersistentStorageChanges(true);
+ Layouter::ReduceLineCache();
+ }
+
bool city = (_settings_game.economy.larger_towns != 0 && Chance16(1, _settings_game.economy.larger_towns));
IncreaseGeneratingWorldProgress(GWP_TOWN);
/* Get a unique name for the town. */