Skip to main content
gamedev.net
🔒 Locked

Slowdown after program ends

Started by dirkduck 12 replies 550+ views
Original Post
dirkduck
dirkduck
Hello everyone. Im calling a function from a DLL in an assembly program. When the program ends, everything becomes really slow, and I have to restart my computer (I''ve tried using things like rambooster but it doesnt help). Ive found out that the fucntion im calling that causes the slowdown is this:
  
void update_entity()
{
	glLoadIdentity();  
	glTranslatef(1.0f,0.0f,-6.0f);	
	glBegin(GL_TRIANGLES);					
	        glVertex3f( 0.0f, 1.0f, 0.0f);			
		glVertex3f(-1.0f,-1.0f, 0.0f);			
		glVertex3f( 1.0f,-1.0f, 0.0f);			
	glEnd();						
	
} 
  
The lines that cause the slowdown are the glVertex3f(...)''s (If I comment them out it runs fine). So im not sure why it slows the computer down after the program has ended. My specs are: Win 98 64MB RAM Celron 400MHz 8MB ATI Rage Pro Turbo Any ideas? Thanks. http://www.labino.net
http://www.labino.net
intransigent-seal
intransigent-seal
Well, I don''t know why that function would cause a slow down, but the common reason for slow downs that happen after the application has ended is a memory leak.

To check, try running the resource meter - when the app starts, the ammount of free memory should go down - if it stays down after you quit the app, then you''ve got a leak.

And make sure that you''re freeing the DLL properly.

John B
The best thing about the internet is the way people with no experience or qualifications can pretend to be completely superior to other people who have no experience or qualifications.
dirkduck
dirkduck
just tried that, and the resource meter didn''t change at all, so I dont think its a memory leak. Also, forgot to add, that once its done, the computer is so slow thats its pretty much un-useable until it has been restarted.

http://www.labino.net
http://www.labino.net
intransigent-seal
intransigent-seal
Weird. How did you find out that update_entity was the problem??

There''s another possibility - an infinite loop could cause a major slowdown.

John B
The best thing about the internet is the way people with no experience or qualifications can pretend to be completely superior to other people who have no experience or qualifications.
dirkduck
dirkduck
I just kept commenting everything out of the assembly file, until that was about all that was left, and found out it was causeing the slowdown. Also, It used to be in an infinet loop, but just to test it, I took out the loop, so it just calls it once, then program ends, and it still has the slowdown.

http://www.labino.net
http://www.labino.net
intransigent-seal
intransigent-seal
Well, I honestly don''t see how that function on its own would cause a slowdown. I would suggest you post more of your code, but I don''t know which bit to ask for. Oh well - post some more code anyway.

John B
The best thing about the internet is the way people with no experience or qualifications can pretend to be completely superior to other people who have no experience or qualifications.
intransigent-seal
intransigent-seal
I assume you''ve done this already, but just to be sure, leave everything in, then run it (make sure the slow down is still there), then comment out only calls to that function, and run it again - if that gets rid of the slowdown, then I have no idea what''s going on - if that doesn''t get rid of the slowdown, then I still don''t know what''s going on, but we''ll have got more information, which could be useful.

John B
The best thing about the internet is the way people with no experience or qualifications can pretend to be completely superior to other people who have no experience or qualifications.
dirkduck
dirkduck
Sure, heres some code from the assembly file:

  
push dword 0
push dword 32
push dword 480
push dword 640
push dword c_i_WindowTitle ;defined earlier
call [CreateGLWindow]
;its just nehe''s createGLwindow function

mov dword [entity_render], 0
renderloop0:
call [update_entity] ;here it is
inc dword [entity_render]
mov dword eax,[entity_render]
cmp dword 2, eax ;render two ''objects''
jne renderloop0


Now, if I run that with the 3 lines that I mentioned in my first post commented out, then it works fine, but if I run it with the 3 lines uncommented, then it causes the slowdown.

http://www.labino.net
http://www.labino.net
dirkduck
dirkduck
Yeah, Ive tried just commenting out that one function call, and it works fine, but when I leave it in, it slows everything. Thanks for the help.

http://www.labino.net
http://www.labino.net
intransigent-seal
intransigent-seal
Sorry - I''d better leave you to the experts now, since I don''t know very much about OpenGL or Assembly.

John B
The best thing about the internet is the way people with no experience or qualifications can pretend to be completely superior to other people who have no experience or qualifications.
sjdibble
sjdibble
I must confess that my assembler is a tad rusty, but looking at the code snippet, I am a little confused over the render loop.

After initialising the OpenGL window you have the following code

mov dword [entity_render], 0
renderloop0:
call [update_entity]
inc dword [entity_render]
mov dword eax,[entity_render]
cmp dword 2, eax ;render two ''objects''
jne renderloop0

I assume that this code is called each frame in order to render ''entity''. I was wondering where you actually enter this loop each frame. If it is before the initialisation of the OpenGL window then you will be initialising every frame.

If each frame, however, you jump to ''renderloop0'', then you are not reseting the [entity_render] value to 0, thus after the first loop, it will already be set to 2. You then increment and compare with 2, looping of not equal. You would have to count all the way round to 2 again. Thats a lot of entities being rendered !

Now, exactly why either of these problems would cause the problem you are describing, I''m not sure, but they could be cause (but I have made a few assumptions which of course may also be wrong)

Stephen
dirkduck
dirkduck
Basiclly, what is happening is, ever loop it resets ''entity_render'' to 0, then, until entity render equals 2, it will render a certain entity (triangle in this case). Meaning that it will only render 2 triangles each frame. All this code is after the openGL window has been created, and right after that loop it wil swap the buffers and then prepare for another render loop. Anyways, the funny thing is, it works fine on a different computer (win98 SE, 64MB RAM, 64MB GeForce2MX), so im wondering if it may be the video card that causes the problem, as old ATI cards dont have much openGL support...although I dont see why this would cause a huge slowdown after the program is finished. Thanks

http://www.labino.net
http://www.labino.net
silvermace
silvermace
ATi Cards are known to have issues with OpenGL
Update ur drivers, the code looks good, try running it on a friends machine (with an *nVidia* card)and see if it still happens
dirkduck
dirkduck
Hey, yeah, I got the latest driver from glSetup, (which didn''t seem to make much of a difference), but Ive tested it on a different comp with simmilar specas, but with a GeForce2 MX and it works fine.

http://www.labino.net
http://www.labino.net

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.