Sign in to follow this  

video memory problem

This topic is 4733 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 using C# and managed directx to write a level editor but im having problems with textures and video memory. From my main window, i got a button that will open an image and create another window where that image will go. Everything is fine except for that after i close the window a very small amount of video memory occupied by the texture is recovered. After experimenting a little, i noticed that if i shrank the window all the video memory would be recovered. Anyone know what might be causing this behaviour or know a solution to this problem?

Share this post


Link to post
Share on other sites
It's fairly common to see artifacts from a previous texture/display appearing in completely unrelated cases... it's simply a case that most graphics drivers don't "clean" the memory they de-allocate.

An old graphics card of mine would crash during games and on a hard-reset the screen would show a corrupted version of the display just prior to the crash for a couple of seconds [grin].

However, solving it can be a bit trickier - its usually a case of checking your texture sizes and allocations. What's probably happening is you're using a texture of the wrong size (and/or reading too much) such that it's pulling in garbage from VRAM. Not clearing the screen before/after every frame can also have similar results..

Without anymore specific code or screenshots or details, its a bit more difficult to say anything clearer!

hth
Jack

Share this post


Link to post
Share on other sites
first of all, thanks for the reply.
I dont think i explained myself correctly. Whats happening is that after loading a lot of textures or a few big ones in to the application i get an out of video memory error. So i made a function that displays the amount of video memory left, and i noticed that if i resized making the window smaller, the amount of available video memory would increase. However, if i increased the size of the window again the amount of video memory available would once again be drop to the number it was when the file was opened Maybe it has something to do with using a Direct3DDevices each for my main window and my tile set window?
btw heres the code for my tile set window where the problems are occuring

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;


public class TileDialog : System.Windows.Forms.Form
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
private string path;
private ESSprite[,] tiles;
private int nHorizontal;
private int nVertical;
private int tileWidth;
private int tileHeight;
private int width =0;
private int height;
private ESRenderer graphics;


public TileDialog(Device display,int TileWidth,int TileHeight,string Path)
{
//
// Required for Windows Form Designer support
//
path = Path;
Setstyle(Controlstyles.AllPaintingInWmPaint | Controlstyles.Opaque,
true);

using( Texture sourceImage = TextureLoader.FromFile(display,path,
D3DX.Default,D3DX.Default,1,Usage.None,Format.Unknown,
Pool.Managed,Filter.None,Filter.None,0))
{

width = sourceImage.GetLevelDescription(0).Width;
height = sourceImage.GetLevelDescription(0).Height;
}



graphics = new ESRenderer(this,false,true,false,true,640,480,
width,height,"effect.fx");




InitializeComponent();

tileWidth = TileWidth;
tileHeight = TileHeight;
nHorizontal = width/TileWidth;
nVertical = height/TileHeight;

tiles = new ESSprite[nHorizontal,nVertical];

for(int x = 0; x < nHorizontal; x++)
{
for(int y = 0; y < nVertical; y++)
{
tiles[x,y] = new ESSprite();
tiles[x,y].ResetObject(graphics.getDevice,x*tileWidth,y*tileHeight,
x*tileWidth,y*tileHeight,0.0f,1,tileWidth,tileHeight,true,path,"SimpleEffect");
}
}



}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();

}
}
base.Dispose( disposing );
}

protected override void OnPaint(PaintEventArgs e)
{
graphics.BeginRender();
for(int x = 0; x < nHorizontal; x++)
{
for(int y = 0; y < nVertical; y++)
{

graphics.RenderSprite(tiles[x,y],(float)ESTimer.GetFrameTime);

}
}

graphics.Draw2DText("Available Texture Memory: \n" + graphics.getDevice.AvailableTextureMemory,
0,0,Color.FromArgb(255,255,0));


graphics.EndRender();


}


#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
//
// TileDialog
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 273);
this.Name = "TileDialog";

}
#endregion




}


Share this post


Link to post
Share on other sites
well i thought the cause of this may have been a bug in the version of managed directx that I was using, so i downloaded and installed the december update. Didnt do a thing :(

Share this post


Link to post
Share on other sites

This topic is 4733 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