Memory issue? Mogre.TexturePtr.!TexturePtr()

CodeKrash

20-12-2010 21:11:14

"Attempted to read or write protected memory. This is often an indication that other memory is corrupt."
at Mogre.TexturePtr.!TexturePtr()
at Mogre.TexturePtr.Dispose(Boolean )
at Mogre.TexturePtr.Finalize()


!TexturePtr()
{
if (_sharedPtr != 0)
{
delete _sharedPtr;
_sharedPtr = 0;
}
}


I tried adding this, but there was no change:

public void shutdown()
{
foreach(TexturePtr ptr in this){
ptr.Unload();
TextureManager.Singleton.Remove(ptr.Handle);
TextureManager.Singleton.Remove((ulong)ptr.NativePtr);
TextureManager.Singleton.Unload(ptr.Handle);
TextureManager.Singleton.Unload((ulong)ptr.NativePtr);
}

TextureManager.Singleton.UnloadAll();
}


The funny thing is, I'm not even using the textures for anything, just loading them manually:

Mogre.Image image = new Mogre.Image();
FileStream fs = new FileStream(pathAbsImg, FileMode.Open);
DataStreamPtr fs2 = new DataStreamPtr(new ManagedDataStream(fs));
image.Load(fs2);
TexturePtr texturePtr = TextureManager.Singleton.LoadImage(pathRelFile, ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME, image);
fs2.Close();
fs.Close();
lock (allTextures)
{
return allTextures.Add(texturePtr);
}


I would be grateful for any/all ideas :D

edit: I guess I need to ask: How do I properly uninitialize these objects?

smiley80

21-12-2010 12:17:55

foreach(TexturePtr ptr in this)
{
ptr.Unload();
TextureManager.Singleton.Remove(ptr.Handle);
ptr.Dispose();
}

should be sufficient.

Also take a look at this thread:
viewtopic.php?f=8&t=13719

CodeKrash

23-12-2010 00:41:34

foreach(TexturePtr ptr in this)
{
ptr.Unload();
TextureManager.Singleton.Remove(ptr.Handle);
ptr.Dispose();
}

should be sufficient.

Also take a look at this thread:
viewtopic.php?f=8&t=13719



Thanks smiley80! That fixed it!