remove circular shared_ptr and a few other memory leaks

This commit is contained in:
Konstantin Käfer
2015-01-19 17:40:24 +01:00
parent 5602ba2f07
commit 31a0d18ca1
14 changed files with 159 additions and 85 deletions

View File

@@ -36,6 +36,10 @@ void VectorTileData::parse() {
}
try {
if (!style) {
throw std::runtime_error("style isn't present in VectorTileData object anymore");
}
// Parsing creates state that is encapsulated in TileParser. While parsing,
// the TileParser object writes results into this objects. All other state
// is going to be discarded afterwards.
@@ -43,6 +47,9 @@ void VectorTileData::parse() {
glyphAtlas, glyphStore,
spriteAtlas, sprite,
texturePool);
// Clear the style so that we don't have a cycle in the shared_ptr references.
style.reset();
parser.parse();
} catch (const std::exception& ex) {
Log::Error(Event::ParseTile, "Parsing [%d/%d/%d] failed: %s", id.z, id.x, id.y, ex.what());