summaryrefslogtreecommitdiffstats
path: root/Source/cmListFileCache.h
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2016-04-12 21:07:08 (GMT)
committerBrad King <brad.king@kitware.com>2016-04-15 14:31:39 (GMT)
commit1f6bd8a93f602f9d4dde1c3ea697211897f25827 (patch)
treee9afa9b5de7df37ab01a2406158acf1d04fdc6b1 /Source/cmListFileCache.h
parent18b6676bff6d50ebc38c75e7998298fca75a01c5 (diff)
downloadCMake-1f6bd8a93f602f9d4dde1c3ea697211897f25827.zip
CMake-1f6bd8a93f602f9d4dde1c3ea697211897f25827.tar.gz
CMake-1f6bd8a93f602f9d4dde1c3ea697211897f25827.tar.bz2
cmState: Avoid accumulating snapshot storage for backtraces
Changes during post-3.3/pre-3.4 development refactored storage of most configure-time information, including variable bindings and function scopes. All scopes (even short-lived) were kept persistently for possible future debugging features, causing huge accumulated memory usage. This was mostly addressed by commit v3.4.1~4^2 (cmState: Avoid accumulating snapshot storage for short-lived scopes, 2015-11-24). Since then we still keep short-lived scopes when they are needed for a backtrace. This is because since commit v3.4.0-rc1~378^2 (cmListFileBacktrace: Implement in terms of cmState::Snapshot, 2015-05-29) backtraces have been lightweight objects that simply point into the snapshot tree. While the intention of this approach was to avoid duplicating the call stack file path strings, the cost turned out to be holding on to the entire call stack worth of scope snapshots, which is much worse. Furthermore, since commit v3.4.0-rc2~1^2 (cmIfCommand: Issue CMP0054 warning with appropriate context, 2015-10-20) all conditions used in `if()` commands hold a backtrace for use in diagnostic messages. Even though the backtrace is short-lived it still causes the scope snapshot to be kept. This means that code like function(foo) if(0) endif() endfunction() foreach(i RANGE 1000000) foo() endforeach() accumulates storage for the function call scope snapshots. Fix this by partially reverting commit v3.4.0-rc1~378^2 and saving the entire call stack during cmListFileBacktrace construction. This way we can avoid keeping short-lived scope snapshot storage in all cases.
Diffstat (limited to 'Source/cmListFileCache.h')
-rw-r--r--Source/cmListFileCache.h3
1 files changed, 1 insertions, 2 deletions
diff --git a/Source/cmListFileCache.h b/Source/cmListFileCache.h
index 4d3055f..d3cab22 100644
--- a/Source/cmListFileCache.h
+++ b/Source/cmListFileCache.h
@@ -87,7 +87,7 @@ struct cmListFileFunction: public cmCommandContext
std::vector<cmListFileArgument> Arguments;
};
-class cmListFileBacktrace
+class cmListFileBacktrace: private std::vector<cmListFileContext>
{
public:
cmListFileBacktrace(cmState::Snapshot snapshot = cmState::Snapshot(),
@@ -97,7 +97,6 @@ class cmListFileBacktrace
void PrintTitle(std::ostream& out) const;
void PrintCallStack(std::ostream& out) const;
private:
- cmCommandContext Context;
cmState::Snapshot Snapshot;
};