Hello, I've been refactoring my project and saw some leaks detected when I run Dr.Memory (as a Visual Studio tool).
Here's the results from Dr.Memory:
Code: Select all
Error #52: LEAK 64 bytes
replace_malloc
D:\a\drmemory\drmemory\common\alloc_replace.c(2580):
RenderSystem_GL3Plus_d.dll!Ogre::CPreprocessor::Token::Append
D:\OGRE_NEXT\ogre-next\RenderSystems\GL3Plus\src\GLSL\OgreGLSLPreprocessor.cpp(91):
RenderSystem_GL3Plus_d.dll!Ogre::CPreprocessor::Parse
D:\OGRE_NEXT\ogre-next\RenderSystems\GL3Plus\src\GLSL\OgreGLSLPreprocessor.cpp(1431):
RenderSystem_GL3Plus_d.dll!Ogre::GLSLShader::loadFromSource
D:\OGRE_NEXT\ogre-next\RenderSystems\GL3Plus\src\GLSL\OgreGLSLShader.cpp(183):
OgreNextMain_d.dll!Ogre::HighLevelGpuProgram::loadHighLevelImpl
D:\OGRE_NEXT\ogre-next\OgreMain\src\OgreHighLevelGpuProgram.cpp(329):
OgreNextMain_d.dll!Ogre::HighLevelGpuProgram::loadHighLevel
D:\OGRE_NEXT\ogre-next\OgreMain\src\OgreHighLevelGpuProgram.cpp(184):
OgreNextMain_d.dll!Ogre::HighLevelGpuProgram::createParameters
D:\OGRE_NEXT\ogre-next\OgreMain\src\OgreHighLevelGpuProgram.cpp(153):
RenderSystem_GL3Plus_d.dll!Ogre::GLSLShader::createParameters
D:\OGRE_NEXT\ogre-next\RenderSystems\GL3Plus\src\GLSL\OgreGLSLShader.cpp(541):
OgreNextMain_d.dll!Ogre::GpuProgram::getDefaultParameters
D:\OGRE_NEXT\ogre-next\OgreMain\src\OgreGpuProgram.cpp(409):
OgreNextMain_d.dll!Ogre::GpuProgramTranslator::translate
D:\OGRE_NEXT\ogre-next\OgreMain\src\OgreScriptTranslator.cpp(4698):
OgreNextMain_d.dll!Ogre::ScriptCompiler::compile
D:\OGRE_NEXT\ogre-next\OgreMain\src\OgreScriptCompiler.cpp(353):
OgreNextMain_d.dll!Ogre::ScriptCompiler::compile
D:\OGRE_NEXT\ogre-next\OgreMain\src\OgreScriptCompiler.cpp(259):
Error #53: LEAK 64 bytes
replace_malloc
D:\a\drmemory\drmemory\common\alloc_replace.c(2580):
RenderSystem_GL3Plus_d.dll!Ogre::CPreprocessor::Token::Append
D:\OGRE_NEXT\ogre-next\RenderSystems\GL3Plus\src\GLSL\OgreGLSLPreprocessor.cpp(91):
RenderSystem_GL3Plus_d.dll!Ogre::CPreprocessor::Parse
D:\OGRE_NEXT\ogre-next\RenderSystems\GL3Plus\src\GLSL\OgreGLSLPreprocessor.cpp(1431):
RenderSystem_GL3Plus_d.dll!Ogre::GLSLShader::loadFromSource
D:\OGRE_NEXT\ogre-next\RenderSystems\GL3Plus\src\GLSL\OgreGLSLShader.cpp(183):
OgreNextMain_d.dll!Ogre::HighLevelGpuProgram::loadHighLevelImpl
D:\OGRE_NEXT\ogre-next\OgreMain\src\OgreHighLevelGpuProgram.cpp(329):
OgreNextMain_d.dll!Ogre::HighLevelGpuProgram::loadHighLevel
D:\OGRE_NEXT\ogre-next\OgreMain\src\OgreHighLevelGpuProgram.cpp(184):
OgreNextMain_d.dll!Ogre::HighLevelGpuProgram::createParameters
D:\OGRE_NEXT\ogre-next\OgreMain\src\OgreHighLevelGpuProgram.cpp(153):
RenderSystem_GL3Plus_d.dll!Ogre::GLSLShader::createParameters
D:\OGRE_NEXT\ogre-next\RenderSystems\GL3Plus\src\GLSL\OgreGLSLShader.cpp(541):
OgreNextMain_d.dll!Ogre::GpuProgram::getDefaultParameters
D:\OGRE_NEXT\ogre-next\OgreMain\src\OgreGpuProgram.cpp(409):
OgreNextMain_d.dll!Ogre::GpuProgramTranslator::translate
D:\OGRE_NEXT\ogre-next\OgreMain\src\OgreScriptTranslator.cpp(4696):
OgreNextMain_d.dll!Ogre::ScriptCompiler::compile
D:\OGRE_NEXT\ogre-next\OgreMain\src\OgreScriptCompiler.cpp(353):
OgreNextMain_d.dll!Ogre::ScriptCompiler::compile
D:\OGRE_NEXT\ogre-next\OgreMain\src\OgreScriptCompiler.cpp(259):
Error #54: LEAK 8 bytes
replace_operator_new
D:\a\drmemory\drmemory\common\alloc_replace.c(2903):
RenderSystem_Direct3D11_d.dll!Ogre::D3D11VendorExtension::initializeExtension
D:\OGRE_NEXT\ogre-next\RenderSystems\Direct3D11\src\VendorExtensions\OgreD3D11VendorExtension.cpp(58):
RenderSystem_Direct3D11_d.dll!Ogre::D3D11RenderSystem::D3D11RenderSystem
D:\OGRE_NEXT\ogre-next\RenderSystems\Direct3D11\src\OgreD3D11RenderSystem.cpp(135):
RenderSystem_Direct3D11_d.dll!Ogre::D3D11Plugin::install
D:\OGRE_NEXT\ogre-next\RenderSystems\Direct3D11\src\OgreD3D11Plugin.cpp(44):
OgreNextMain_d.dll!Ogre::Root::installPlugin
D:\OGRE_NEXT\ogre-next\OgreMain\src\OgreRoot.cpp(1426):
RenderSystem_Direct3D11_d.dll!dllStartPlugin
D:\OGRE_NEXT\ogre-next\RenderSystems\Direct3D11\src\OgreD3D11EngineDll.cpp(40):
DerivedGraphicsSystem::initialize
D:\OGRE_NEXT\game\src\OgreDerived\DerivedGraphicsSystem.cpp(58):
WinMain
D:\OGRE_NEXT\game\src\main.cpp(72):
Error #55: LEAK 64 bytes
replace_malloc
D:\a\drmemory\drmemory\common\alloc_replace.c(2580):
RenderSystem_GL3Plus_d.dll!Ogre::CPreprocessor::Token::Append
D:\OGRE_NEXT\ogre-next\RenderSystems\GL3Plus\src\GLSL\OgreGLSLPreprocessor.cpp(91):
RenderSystem_GL3Plus_d.dll!Ogre::CPreprocessor::Parse
D:\OGRE_NEXT\ogre-next\RenderSystems\GL3Plus\src\GLSL\OgreGLSLPreprocessor.cpp(1431):
RenderSystem_GL3Plus_d.dll!Ogre::GLSLShader::loadFromSource
D:\OGRE_NEXT\ogre-next\RenderSystems\GL3Plus\src\GLSL\OgreGLSLShader.cpp(183):
OgreNextMain_d.dll!Ogre::HighLevelGpuProgram::loadHighLevelImpl
D:\OGRE_NEXT\ogre-next\OgreMain\src\OgreHighLevelGpuProgram.cpp(329):
OgreNextMain_d.dll!Ogre::HighLevelGpuProgram::loadHighLevel
D:\OGRE_NEXT\ogre-next\OgreMain\src\OgreHighLevelGpuProgram.cpp(184):
OgreNextMain_d.dll!Ogre::HighLevelGpuProgram::createParameters
D:\OGRE_NEXT\ogre-next\OgreMain\src\OgreHighLevelGpuProgram.cpp(153):
RenderSystem_GL3Plus_d.dll!Ogre::GLSLShader::createParameters
D:\OGRE_NEXT\ogre-next\RenderSystems\GL3Plus\src\GLSL\OgreGLSLShader.cpp(541):
OgreNextMain_d.dll!Ogre::UnifiedHighLevelGpuProgram::createParameters
D:\OGRE_NEXT\ogre-next\OgreMain\src\OgreUnifiedHighLevelGpuProgram.cpp(153):
OgreNextMain_d.dll!Ogre::GpuProgramUsage::recreateParameters
D:\OGRE_NEXT\ogre-next\OgreMain\src\OgreGpuProgramUsage.cpp(230):
OgreNextMain_d.dll!Ogre::GpuProgramUsage::setProgramName
D:\OGRE_NEXT\ogre-next\OgreMain\src\OgreGpuProgramUsage.cpp(105):
OgreNextMain_d.dll!Ogre::Pass::setFragmentProgram
D:\OGRE_NEXT\ogre-next\OgreMain\src\OgrePass.cpp(846):
Error #56: LEAK 64 bytes
replace_malloc
D:\a\drmemory\drmemory\common\alloc_replace.c(2580):
RenderSystem_GL3Plus_d.dll!Ogre::CPreprocessor::Token::Append
D:\OGRE_NEXT\ogre-next\RenderSystems\GL3Plus\src\GLSL\OgreGLSLPreprocessor.cpp(91):
RenderSystem_GL3Plus_d.dll!Ogre::CPreprocessor::Parse
D:\OGRE_NEXT\ogre-next\RenderSystems\GL3Plus\src\GLSL\OgreGLSLPreprocessor.cpp(1431):
RenderSystem_GL3Plus_d.dll!Ogre::GLSLShader::loadFromSource
D:\OGRE_NEXT\ogre-next\RenderSystems\GL3Plus\src\GLSL\OgreGLSLShader.cpp(183):
OgreNextMain_d.dll!Ogre::HighLevelGpuProgram::loadHighLevelImpl
D:\OGRE_NEXT\ogre-next\OgreMain\src\OgreHighLevelGpuProgram.cpp(329):
OgreNextMain_d.dll!Ogre::HighLevelGpuProgram::loadHighLevel
D:\OGRE_NEXT\ogre-next\OgreMain\src\OgreHighLevelGpuProgram.cpp(184):
OgreNextMain_d.dll!Ogre::HighLevelGpuProgram::loadImpl
D:\OGRE_NEXT\ogre-next\OgreMain\src\OgreHighLevelGpuProgram.cpp(113):
OgreNextMain_d.dll!Ogre::Hlms::compileShaderCode
D:\OGRE_NEXT\ogre-next\OgreMain\src\OgreHlms.cpp(2244):
OgreNextMain_d.dll!Ogre::Hlms::_compileShaderFromPreprocessedSource
D:\OGRE_NEXT\ogre-next\OgreMain\src\OgreHlms.cpp(2279):
OgreNextMain_d.dll!Ogre::HlmsDiskCache::_compileShadersThread
D:\OGRE_NEXT\ogre-next\OgreMain\src\OgreHlmsDiskCache.cpp(203):
OgreNextMain_d.dll!Ogre::HlmsDiskCache::applyTo
D:\OGRE_NEXT\ogre-next\OgreMain\src\OgreHlmsDiskCache.cpp(307):
Demo::GraphicsSystem::loadHlmsDiskCache
D:\OGRE_NEXT\ogre-next\Samples\2.0\Common\src\GraphicsSystem.cpp(637):
===========================================================================
FINAL SUMMARY:
DUPLICATE ERROR COUNTS:
Error # 3: 1690
Error # 4: 1937
Error # 5: 422
Error # 6: 1690
Error # 7: 1937
Error # 8: 422
Error # 12: 2
Error # 13: 3
Error # 14: 2
Error # 15: 3
Error # 16: 2
Error # 17: 3
Error # 18: 2
Error # 19: 3
Error # 20: 2
Error # 21: 3
Error # 22: 2
Error # 23: 3
Error # 26: 3
Error # 28: 3
Error # 30: 3
Error # 32: 3
Error # 34: 3
Error # 36: 3
Error # 38: 3
Error # 40: 3
Error # 42: 3
Error # 44: 3
Error # 46: 3
Error # 48: 3
Error # 49: 118
Error # 50: 8
Error # 51: 5
Error # 52: 13
Error # 53: 5
Error # 55: 3
Error # 56: 2
SUPPRESSIONS USED:
ERRORS FOUND:
0 unique, 0 total unaddressable access(es)
51 unique, 8313 total uninitialized access(es)
0 unique, 0 total invalid heap argument(s)
0 unique, 0 total GDI usage error(s)
0 unique, 0 total handle leak(s)
0 unique, 0 total warning(s)
5 unique, 24 total, 1480 byte(s) of leak(s)
0 unique, 0 total, 0 byte(s) of possible leak(s)
This could be false positive but I'm reporting it here just in case.
My program uses a derived class from GraphicsSystem, which initialize differently so that I can pass in an external window handle in main function. Here's DerivedGraphicsSystem initialize and deinitialize:
Code: Select all
void DerivedGraphicsSystem::initialize(
HWND& hwnd,
const char* pluginsFile,
int& width, int& height,
bool& fullscreen
)
{
const Ogre::String windowTitle = "Window's Title";
mWinHandle = hwnd;
const Ogre::AbiCookie abiCookie = Ogre::generateAbiCookie();
mRoot = OGRE_NEW Ogre::Root( &abiCookie,
mPluginsFolder + pluginsFile,
mWriteAccessFolder + "ogre.cfg",
mWriteAccessFolder + "Ogre.log",
windowTitle);
mStaticPluginLoader.install( mRoot );
// enable sRGB Gamma Conversion mode by default for all renderers,
// but still allow to override it via config dialog
Ogre::RenderSystemList::const_iterator itor = mRoot->getAvailableRenderers().begin();
Ogre::RenderSystemList::const_iterator endt = mRoot->getAvailableRenderers().end();
while( itor != endt )
{
Ogre::RenderSystem *rs = *itor;
rs->setConfigOption( "sRGB Gamma Conversion", "Yes" );
++itor;
}
//mAlwaysAskForConfig = false;
if( mAlwaysAskForConfig || !mRoot->restoreConfig() )
{
if( !mRoot->showConfigDialog() )
{
mQuit = true;
return;
}
}
mRoot->initialise( false );
Ogre::ConfigOptionMap &cfgOpts = mRoot->getRenderSystem()->getConfigOptions();
Ogre::ConfigOptionMap::iterator opt = cfgOpts.find( "Video Mode" );
if( opt != cfgOpts.end() && !opt->second.currentValue.empty() )
{
// Ignore leading space
const Ogre::String::size_type start = opt->second.currentValue.find_first_of( "012356789" );
// Get the width and height
Ogre::String::size_type widthEnd = opt->second.currentValue.find( ' ', start );
// we know that the height starts 3 characters after the width and goes until the next space
Ogre::String::size_type heightEnd = opt->second.currentValue.find( ' ', widthEnd + 3 );
// Now we can parse out the values
width = Ogre::StringConverter::parseInt( opt->second.currentValue.substr( 0, widthEnd ) );
height = Ogre::StringConverter::parseInt( opt->second.currentValue.substr( widthEnd + 3, heightEnd ) );
}
fullscreen = Ogre::StringConverter::parseBool( cfgOpts["Full Screen"].currentValue );
Ogre::NameValuePairList params;
// insert external window handle (hwnd) and set the window's position
params.insert(std::make_pair("externalWindowHandle", Ogre::StringConverter::toString((unsigned long long)mWinHandle)));
SetWindowPos(mWinHandle, HWND_TOP, 0, 0, width, height, 0);
//-----------------------
params.insert( std::make_pair( "title", "" ) );
params.insert( std::make_pair( "gamma", cfgOpts["sRGB Gamma Conversion"].currentValue ) );
if( cfgOpts.find( "VSync Method" ) != cfgOpts.end() )
params.insert( std::make_pair( "vsync_method", cfgOpts["VSync Method"].currentValue ) );
params.insert( std::make_pair( "FSAA", cfgOpts["FSAA"].currentValue ) );
params.insert( std::make_pair( "vsync", cfgOpts["VSync"].currentValue ) );
params.insert( std::make_pair( "reverse_depth", "Yes" ) );
initMiscParamsListener( params );
mRenderWindow = Ogre::Root::getSingleton().createRenderWindow(
"Main RenderWindow",
static_cast<uint32_t>( width ), static_cast<uint32_t>( height ),
fullscreen, ¶ms );
mOverlaySystem = OGRE_NEW Ogre::v1::OverlaySystem();
setupResources();
loadResources();
chooseSceneManager();
createCamera();
mWorkspace = setupCompositor();
}
//---------------------------------------------------------------------------------------
void DerivedGraphicsSystem::deinitialize()
{
saveTextureCache();
saveHlmsDiskCache();
if (mSceneManager)
{
Ogre::AtmosphereComponent* atmosphere = mSceneManager->getAtmosphereRaw();
OGRE_DELETE atmosphere;
mSceneManager->removeRenderQueueListener(mOverlaySystem);
}
OGRE_DELETE mOverlaySystem;
mOverlaySystem = 0;
OGRE_DELETE mRoot;
mRoot = 0;
}