Weird dispose issue [SOLVED]

mzanin

14-10-2010 20:08:53

I must be going crazy but could someone enlighten me as to why

var texture = TextureManager.Singleton.GetByName(m_TextureName);

if (texture != null)
{
TextureManager.Singleton.Remove(m_TextureName);
}

causes an AccessViolationException every time... and this:


TextureManager.Singleton.Remove(m_TextureName);


does not?

I don't know what the stack trace etc. is because I'm running from a release build of Mogre 1.7.1.

mzanin

27-10-2010 13:30:39

In case someone else runs into this problem I'll post the solution.

TextureManager.Singleton.GetByName returns a Ptr object. It needs to be destroyed after use otherwise unexpected behaviour and memory leaks can occur.

AliAkdurak

07-12-2010 12:35:07

If you want to clear definition of why and how you can check here. I am adding this post in case someone needs it.

http://www.ogre3d.org/addonforums/viewtopic.php?f=8&t=13719