From c1e34c5a29d99d8a70b4e78313bfd3d539d9206e Mon Sep 17 00:00:00 2001 From: Jay Kwak <82421531+jkwak-work@users.noreply.github.com> Date: Tue, 28 May 2024 11:31:03 -0700 Subject: Print memory leak info in Debug build of slangc.exe (#4210) When memory leak is detected, this commit will dump the information about the memory leak. This feature is available only in Debug build on Windows platform. Also note that the message will not be printed on the client applications that use slang.dll, because the printing happens as a part of slangc.exe not slang.dll. I found a bug that Slang::StdWriters was closing `stdout` and `stderr` in its destructor, which prevented Crt functions to print the messages to `stdout` and `stderr`. --- source/core/slang-std-writers.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/core/slang-std-writers.cpp') diff --git a/source/core/slang-std-writers.cpp b/source/core/slang-std-writers.cpp index bf3ae72fd..a23d878fb 100644 --- a/source/core/slang-std-writers.cpp +++ b/source/core/slang-std-writers.cpp @@ -10,8 +10,8 @@ namespace Slang { RefPtr stdWriters(new StdWriters); - RefPtr stdError(new FileWriter(stderr, WriterFlag::AutoFlush)); - RefPtr stdOut(new FileWriter(stdout, WriterFlag::AutoFlush)); + RefPtr stdError(new FileWriter(stderr, WriterFlag::AutoFlush | WriterFlag::IsUnowned)); + RefPtr stdOut(new FileWriter(stdout, WriterFlag::AutoFlush | WriterFlag::IsUnowned)); stdWriters->setWriter(SLANG_WRITER_CHANNEL_STD_ERROR, stdError); stdWriters->setWriter(SLANG_WRITER_CHANNEL_STD_OUTPUT, stdOut); -- cgit v1.2.3