using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
class TextureContainer
{
Texture2D tex;
public TextureContainer(GraphicsDevice gd)
{
tex = new Texture2D(gd, 1, 1);
}
~TextureContainer()
{
tex.Dispose();
}
}
class Program : Game
{
static void Main(string[] args)
{
using (Program p = new Program())
{
new GraphicsDeviceManager(p);
p.Run();
}
}
protected override void Draw(GameTime gameTime)
{
new TextureContainer(GraphicsDevice);
if (gameTime.TotalGameTime > TimeSpan.FromSeconds(10))
{
GC.Collect();
}
base.Draw(gameTime);
}
}
Test program: