SpriteFont with BMFont fonts seems to leak after being disposed. #167
Comments
maybe in SpriteFont.cs#L166 the Texture2D being loaded and assigned to bitmapName is not being disposed? |
i could quickfix it by explicitly disposing all textures like this:
but i guess, this does not follow the SharpDX coding style ;-) |
Here are the results of my analysis so far: The first location is a static context - so we can't wrap it in ToDispose, second location is not suitable too as SpriteFontData is not disposable, so the only point where the texture can be registered for disposal - is the last location. But the problem is that the same SpriteFontData potentially can be reused to create several SpriteFont object, and disposal of one will invalidate the others which share the same glyph texture. The issue can be reproduced only in case when SpriteFont is loaded manually - when it is loaded via ContentManager it will dispose the resources correctly, so until this will be fixed - load fonts via |
thanks for the info! when does it make sense to create another SpriteFont object with the same SpriteFontData? due to the architecture of my project, i cant use ContentManager. offtopic: how do you make these links to the sourcecode lines in github? |
…dispose unmanaged resources from SpriteFontData.
The issue should be fixed now. If developer will decide to load SpriteFontData manually - it is his responsibility to dispose correctly the resources (or it can pass the flag as true - look a the commit above).
It all depends on the developer, we just need to make sure that it will behave as expected. This could be used to load some custom font format with variable properties, for example.
Format it as markdown link. |
Hi, I havent found the exact cause yet, but if you do this over and over again.
Then the GPU memory increases. (Managed heap memory also increases but only by a little)
Using NVIDIA Nsight, I found that D3D11Texture2D without ShaderResourceView remain allocated.
I'll update this issue once I find more details.
The text was updated successfully, but these errors were encountered: