From 64eec046f5a77ebad9564a935c4fad8df08ea6eb Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Thu, 20 Jun 2019 11:14:51 -0400 Subject: Hot fix: Remove getExecutablePath reported memory leak (#993) * Remove the memory leak that is being reported on Visual Stuio, due to getExecutablePath having a static local variable that is not freed before leaks are dumped. The solution is sort of clumsy, in so far as it just removes the cache. Would be nice to have a better way to handle such situations. * Add to do comment - and also to push CI to rebuild. --- source/core/slang-io.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'source/core') diff --git a/source/core/slang-io.cpp b/source/core/slang-io.cpp index 3e0aa22a3..6cdd75c74 100644 --- a/source/core/slang-io.cpp +++ b/source/core/slang-io.cpp @@ -549,8 +549,12 @@ namespace Slang /* static */String Path::getExecutablePath() { - static String executablePath = _getExecutablePath(); - return executablePath; + // TODO(JS): It would be better if we lazily evaluated this, and then returned the same string on subsequent calls, because it has to do + // a fair amount of work depending on target. + // This was how previous code worked, with a static variable. Unfortunately this led to a memory leak being reported - because reporting + // is done before a global variable is released. + // It would be good to have a mechanism that allows 'core' library source free memory in some controlled manner. + return _getExecutablePath(); } Slang::String File::readAllText(const Slang::String& fileName) -- cgit v1.2.3