Sign in to follow this  

Problems with Making the Application class a singleton (Ogre)

This topic is 4197 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am just starting with ogre and was trying to get things up and running. One of the things I did first was make the Application class a singleton, I figured I wasnt ever going to need more then one but now the mem leak log is reporting leaks all over the place dealing with the ogre application class heres the code
#pragma once
#include <ExampleApplication.h>
#include <vector>
#include <OgreNewt.h>



class Application:
	public ExampleApplication
{
public:
	~Application(void);
	static Application* Instance(void)
	{
	  if(pInstance == 0)
		  pInstance = new Application();
	  return pInstance;
	}
	Ogre::SceneNode* getCamNode(){return msnCam;}
	Ogre::SceneManager* getSceneMgr(){return mSceneMgr;}
	Ogre::Camera* getCamera(){return mCamera;}
	Ogre::RenderWindow* getWindow(){return mWindow;}

protected:
	void createFrameListener();
	void createScene();

private:
	Application(void);
	static Application* pInstance;
	Ogre::SceneNode* msnCam;
};





everything appears fine within the code so I figure it must be the way that ogre uses the class, it doesnt like the fact its singleton. Anyone have similar problems or solutions or maybe im way off base on the source of the leaks. heres part of the log
Alloc.   Addr       Size       Addr       Size                        BreakOn BreakOn              
Number Reported   Reported    Actual     Actual     Unused    Method  Dealloc Realloc Allocated by 
------ ---------- ---------- ---------- ---------- ---------- -------- ------- ------- --------------------------------------------------- 
000012 0x066E0F90 0x00000024 0x066E0F80 0x00000044 0x00000000 new         N       N    ogrenewtonapplication.h(16) OgreNewtonApplication::Instance
000013 0x066E1000 0x00000014 0x066E0FF0 0x00000034 0x00000000 new         N       N    ogrenewtonapplication.cpp(18) OgreNewtonApplication::OgreNewtonApplic
000014 0x066E1060 0x00000008 0x066E1050 0x00000028 0x00000000 new         N       N    ogrenewt_world.cpp(23) OgreNewt::World::World
000015 0x066E10B8 0x000001C4 0x066E10A8 0x000001E4 0x00000000 new         N       N    exampleapplication.h(75) ExampleApplication::setup
000016 0x066E12C8 0x00000034 0x066E12B8 0x00000054 0x00000000 new         N       N    ??(0) ??
000017 0x066E1348 0x00000034 0x066E1338 0x00000054 0x00000000 new         N       N    ??(0) ??
000018 0x066E13C8 0x00000014 0x066E13B8 0x00000034 0x00000000 new         N       N    ??(0) ??
000019 0x066E1428 0x00000014 0x066E1418 0x00000034 0x00000000 new         N       N    ??(0) ??
000020 0x066E1578 0x00000034 0x066E1568 0x00000054 0x00000000 new         N       N    ogreroot.cpp(144) Ogre::Root::Root
000023 0x066E16B8 0x00000034 0x066E16A8 0x00000054 0x00000000 new         N       N    ??(0) ??
000021 0x066E1788 0x00000034 0x066E1778 0x00000054 0x00000000 new         N       N    ??(0) ??
000022 0x066E1808 0x000000B0 0x066E17F8 0x000000D0 0x00000000 new         N       N    ogrelogmanager.cpp(61) Ogre::LogManager::createLog
000024 0x066E1A10 0x00000020 0x066E1A00 0x00000040 0x00000000 new         N       N    ogreroot.cpp(149) Ogre::Root::Root
000025 0x066E1A80 0x00000034 0x066E1A70 0x00000054 0x00000000 new         N       N    ??(0) ??
000026 0x066E1B00 0x0000003C 0x066E1AF0 0x0000005C 0x00000000 new         N       N    ogreroot.cpp(151) Ogre::Root::Root
000027 0x066E1B88 0x00000034 0x066E1B78 0x00000054 0x00000000 new         N       N    ??(0) ??
000028 0x066E1C08 0x00000034 0x066E1BF8 0x00000054 0x00000000 new         N       N    ??(0) ??
000029 0x066E1C88 0x00000090 0x066E1C78 0x000000B0 0x00000000 new         N       N    ogreroot.cpp(154) Ogre::Root::Root
000030 0x066E1D68 0x00000034 0x066E1D58 0x00000054 0x00000000 new         N       N    ??(0) ??
000031 0x066E1DE8 0x00000018 0x066E1DD8 0x00000038 0x00000000 new         N       N    ??(0) ??
000032 0x066E1E50 0x00000034 0x066E1E40 0x00000054 0x00000000 new         N       N    ??(0) ??
000033 0x066E3F80 0x000000CC 0x066E3F70 0x000000EC 0x00000000 new         N       N    ogreresourcegroupmanager.cpp(91) Ogre::ResourceGroupManager::createResou
000034 0x066E4098 0x0000000C 0x066E4088 0x0000002C 0x00000000 new         N       N    ??(0) ??
000035 0x066E40F0 0x00000034 0x066E40E0 0x00000054 0x00000000 new         N       N    ??(0) ??
000036 0x066E4170 0x00000034 0x066E4160 0x00000054 0x00000000 new         N       N    ??(0) ??
000037 0x066E41F0 0x00000068 0x066E41E0 0x00000088 0x00000000 new         N       N    ??(0) ??
000038 0x066E42A8 0x00000018 0x066E4298 0x00000038 0x00000000 new         N       N    ??(0) ??
000039 0x066E4310 0x00000034 0x066E4300 0x00000054 0x00000000 new         N       N    ??(0) ??
000040 0x066E4390 0x000000CC 0x066E4380 0x000000EC 0x00000000 new         N       N    ogreresourcegroupmanager.cpp(91) Ogre::ResourceGroupManager::createResou
000041 0x066E44A8 0x0000000C 0x066E4498 0x0000002C 0x00000000 new         N       N    ??(0) ??
000042 0x066E4500 0x00000034 0x066E44F0 0x00000054 0x00000000 new         N       N    ??(0) ??
000043 0x066E4580 0x00000034 0x066E4570 0x00000054 0x00000000 new         N       N    ??(0) ??
000044 0x066E4600 0x00000068 0x066E45F0 0x00000088 0x00000000 new         N       N    ??(0) ??
000045 0x066E46B8 0x00000018 0x066E46A8 0x00000038 0x00000000 new         N       N    ??(0) ??
000046 0x066E4720 0x00000034 0x066E4710 0x00000054 0x00000000 new         N       N    ??(0) ??
000047 0x066E47A0 0x000000CC 0x066E4790 0x000000EC 0x00000000 new         N       N    ogreresourcegroupmanager.cpp(91) Ogre::ResourceGroupManager::createResou
000048 0x066E48B8 0x0000000C 0x066E48A8 0x0000002C 0x00000000 new         N       N    ??(0) ??
000049 0x066E4910 0x00000034 0x066E4900 0x00000054 0x00000000 new         N       N    ??(0) ??
000050 0x066E4990 0x00000034 0x066E4980 0x00000054 0x00000000 new         N       N    ??(0) ??
000051 0x066E4A10 0x00000068 0x066E4A00 0x00000088 0x00000000 new         N       N    ??(0) ??
000052 0x066E4AC8 0x00000018 0x066E4AB8 0x00000038 0x00000000 new         N       N    ??(0) ??
000053 0x066E4B30 0x00000034 0x066E4B20 0x00000054 0x00000000 new         N       N    ??(0) ??
000054 0x066E4BB0 0x00000040 0x066E4BA0 0x00000060 0x00000000 new         N       N    ogreroot.cpp(157) Ogre::Root::Root
000055 0x066E4C40 0x00000080 0x066E4C30 0x000000A0 0x00000000 new         N       N    ??(0) ??
000056 0x066E4D10 0x00000018 0x066E4D00 0x00000038 0x00000000 new         N       N    ??(0) ??
000057 0x066E4D78 0x0000009C 0x066E4D68 0x000000BC 0x00000000 new         N       N    ogreroot.cpp(160) Ogre::Root::Root
000058 0x066E4E60 0x0000000C 0x066E4E50 0x0000002C 0x00000000 new         N       N    ??(0) ??
000059 0x066E4EB8 0x00000034 0x066E4EA8 0x00000054 0x00000000 new         N       N    ??(0) ??
000060 0x066E4F38 0x0000000C 0x066E4F28 0x0000002C 0x00000000 new         N       N    ??(0) ??
000061 0x066E4F90 0x00000004 0x066E4F80 0x00000024 0x00000000 new         N       N    ??(0) ??
000062 0x066E4FE0 0x00000300 0x066E4FD0 0x00000320 0x00000000 new         N       N    ogreroot.cpp(164) Ogre::Root::Root





I figure these are chain leaks steming off my application problem because there is no way I altered the code to cause leaks in that many places Thanks for your time [smile]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
It looks like you forgot to delete your pointer to Root. IIRC Root's destructor cleans up everything so if you don't delete the pointer....

Share this post


Link to post
Share on other sites

This topic is 4197 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this