Process not dying

hsv

Newcomer
Joined
Feb 26, 2004
Messages
9
Hey!

I'm trying to learn d3d by developing this game (sidescroller, somewhat like shadow of the beast, if you remember). For the background I use tiles (3 rows as of now).

The problem: after I kill the app, the process is still alive.
I dipose my vertex buffers, but obviously I'm missing something.. Could anyone give me some pointers?
I should probably say that all objects are separated from the Form-class, and uses it to render themselves.
/h
 
Are you closing all your resources properly? Are you using any threading?
If possible could you post some code - it makes it a lot easier for people to help if they can see what you are trying to do.
 
Ok, what I do is this:

For each background (that is, a series of GameObjects = quads), calculate coordinates for the texture and:
Code:
private void setupBackground()
{
	for(int i = 0; i<this.tiles.Length; i++)
	{
		tiles[i] = new GameObject(this.device, (i * TILESIZE), this.yPosition, TILESIZE, TILESIZE);
		tiles[i].setTextureCoords(this.texCoords[i][0], this.texCoords[i][1], this.texCoords[i][2], this.texCoords[i][3]);
	}
}

the cleanup i do for the background. Each tile (GameObject) disposes of its vertexBuffer:
Code:
public void cleanUp()
{
	for(int i=0; i<tiles.Length; i++)
	{
		tiles[i].cleanUp();
	}
	t.Dispose(); // texture
 }
And finally, after calling cleanup for all backgrounds, the form-class calls dispose for the device.

Running, this app uses 25-30% CPU, and when shut-down it jumps to 99% and stays there until I kill it myself.
/h
 
Hmm ive done that before.

Are you sure youve created an exit condition for your main loop (or all loops for that matter) make sure to set running = false or what ever condition is needed to exit all loops before you call the end statement or whatever you quit with.
 
What I do is:
Code:
static void Main() 
{
	rForm rf = new rForm();
	//Init graphics
	rf.initGFX();
	rf.Show();

	while(rf.Created)
	{
		rf.Render();
		Application.DoEvents();
	}
	rf.cleanUp();
}
where rf is the form.
If I set some breakpoints and run with the debugger, it actually dies by itself, but it takes quite a while to get out of the while-loop for some reason. what render does here is call render for my background objects, who in turn lets the tiles render to the form..
Code:
for(int i=0; i<tiles.Length; i++)
{
	tiles[i].Render();
}
..in the usual way (I guess)..
Code:
public void Render()
{
	initObject();
	device.VertexFormat=CustomVertex.TransformedTextured.Format;
	device.SetStreamSource(0, vBuffer, 0);
	device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
}
Is 'while(rf.Created)' my problem?
/h
 
It appears so

Im only a VB programmer so i dont really understand your code 100% but in my experiance id say you whould run the main loop on a boolean variable not a member of a class if you have an event like device.lostfocus that would cause it to quit the game or in your case form.exiting or whatever the appropriet event is add a sub to handle said event and just change the boolean to false then. Try it if it fails then hey ill admit im wrong.
 
I've tried using a boolean, too, responding to a key-event. It works while running it inside VS using the debugger, but not otherwise (same as with the form.Created condition).
After testing a bit by commenting out the rendering of two of my backgrounds and running only the third, it does shut down after about 10 sec. So am I doing this the wrong way, creating an object for each tile? They only contain a vertexBuffer, coordinates for the texture and their position, so..
/h
 
Last edited:
In My experiance

I have found that disposing of the DX objects does take 5-10 seconds when exiting an application, Less when compiled and even less when running with a release version of dx instead of a Debug version this time was much more apparent with DX8 in VB6 However it still seems to be there in VB.net and DX9.
 
I compiled in release mode , and ran it with the release version of dx. Five minutes after I shut it down, the process was still at 99% and I killed it. What I don't understand is why a third object of the same class can mess it up like this. There are 16 more tiles and a texture, thats all!
/h
 
After 5 Minutes

And assuming your processor speed can be measured in mega hertz without decimals im guessing that there is still a loop going somewhere in the program, DX simply has never been that long when disposing, even with my code and i assure you if any programmer is going to find a way to screw something up in the most idiodic fassion possible i would be supprised if it wasnt me. (note my programming is effectivly self taught outside a very basic course in vb6 "this is a form... This is a button, you can put a button on a form.,.. This is a message box... etc..."
 
Thanks for the interest, I got it working now..
You're not the only one who can screw up, trust me :)
I made a lot of changes, but I guess not disposing of the device before cleaning up the resources helped.

/h
 
Back
Top