• Advertisement
Sign in to follow this  

C# and MDX slowdown issue

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

Hi Basically i have a wierd framerate issue. when i start my game with debugging i get an fps of 150 however if i open the windows task manager up my framerate jumbs up to 300....... what is going on? Does anyone know? Thanks

Share this post


Link to post
Share on other sites
Advertisement
I believe debugging mode will often have a slower frame rate. When you compile as a release, it'll be faster. I think the best idea is to always lock it to a certain max fps such as: while ((GetTickCount() - start_time) < 33); or something in that regards.

Share this post


Link to post
Share on other sites
I'm not sure why that happens, maybe it's because the window looses focus and the rendering loop (or some computations) are skipped which gives you a higher frame rate.
You shouldn't be concerned by this though.

The most objective way to chech your framerate is to compile the game in release mode and run it independently (outside your compilier). Make sure you use the DX release runtimes when you do this.

[Edited by - Calin on April 7, 2006 2:59:51 PM]

Share this post


Link to post
Share on other sites
Taking any sort of performance measurement using a debug build of your software, active debugging or the debug DirectX runtimes is going to be misleading.

You really need to try using release builds of everything with no external monitoring tools to judge the true performance.

hth
Jack

Share this post


Link to post
Share on other sites
I can't repro with any of the SDK samples so its either a machine thing or a code specific thing.

How are you measuring your FPS?

Share this post


Link to post
Share on other sites
ok basically what i noticed in general is that my application slows down after many hours.

I decided to run some performance tests to see whats going on and the first one was to check for any weird activity on the task manager and this is where i basically noticed the above problem.

however after i rebooted my machine my framerate was sky high again...

now is it possible to create a memory leak with managed directx and and c#?


what could lead a managed application to degrade slowly?

i never release manually any resources and some of my buffers are created with default and managed.

am i forgeting something?

Share this post


Link to post
Share on other sites
I'm not sure if I should mention this here, but I've noticed a difference between similar DX and MDX samples in the Windows Task Manager. Specifically, the C++(unmanaged) Text3D sample in the Feb 2006 SDK is a 466KB executable taking about 11,000 K of memory - on the other hand, the C# Text3D sample is a 234KB executable taking 8,500 K of memory when active and 1,200 K when minimized. I'm not sure if this is an accurate way to determine which is more efficient, but isn't a .net application always supposed to take up more memory than native code?

Share this post


Link to post
Share on other sites
I'd have a close look at your game loop. I would guess that the loop is being triggered faster if a different window is open, making the game run faster.

Memory leaks shouldn't directly influence speed, unless you are actively leaking the memory during runtime, I think.

Quote:
Original post by obi-wan shinobi
I'm not sure if I should mention this here, but I've noticed a difference between similar DX and MDX samples in the Windows Task Manager. Specifically, the C++(unmanaged) Text3D sample in the Feb 2006 SDK is a 466KB executable taking about 11,000 K of memory - on the other hand, the C# Text3D sample is a 234KB executable taking 8,500 K of memory when active and 1,200 K when minimized. I'm not sure if this is an accurate way to determine which is more efficient, but isn't a .net application always supposed to take up more memory than native code?


There's a high probability these applications are completely different. There isn't any rule of thumb on which of the two should be more or less efficient, and it would really depend on exactly what each is doing. Considering the two are quite different, the likelyhood they're both doing the same thing is extremely low.

Hope this helps.

Share this post


Link to post
Share on other sites
Quote:
Original post by Baltz
now is it possible to create a memory leak with managed directx and and c#?

what could lead a managed application to degrade slowly?


Though its not really the same thing as a C++ memory leak its certainly possible to keep on using up more and more memory until things start to swap out and the garbage collector fires far more often than it should. However this would be per run of your application. When you close the app everything will (eventually - does you app take minutes to go back to VS when you quit?) get tidied up.

There is a particular problem with MDX if you have AutoEvents turned on. Every DX object you create will automatically have event handlers added to it so the device can notify it of lost/destroyed etc. This means that unlike regular objects the GC won't tidy them up unless you explicitly dispose them because the device will always keep a reference. Tom talked about this on a blog a LONG time ago . However, once you quit your app .Net should tidy up everything eventually because the device will be disposed. Try turning off the autoevents if you are not using them.

If it was a memory issue you can watch that with perfmon, you can also watch how often the GC fires - if after several hours of running memory usage is high and the GC is firing a lot then there probably is something to look at.

Finally, non of this explains why framerate would go up when you switch to taskmanager. Does it go up when you switch to any other application? If so see if you are doing anything special on lost focus - if you are using the dxframework it starts sleeping more between frames when the app is not the front most (though this makes your framerate drop not rise).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement