Archived

This topic is now archived and is closed to further replies.

djc

DirectPlay in DX9 using C# - Client/Server-Game

Recommended Posts

I seem to have a problem with DirectPlay...are at least, so I think.... We are working on a little Mutliplayer game using C#/Managed DirectX9. We seem to have this really strange problem.....the game works fine for a while...then suddenly the messages sent between server and clients don''t seem to transfer smoothly anymore and the game starts to become really slow. The game is in 2D (DirectDraw), it is comparable to a game like BomberMan.... We notice the problem seems to happen after about 3000 message have been sent between client and server (2 Players in game). First the problem happened after about 1500 messages.....back then, we just sent a message for every player move....so we implemented dead reckoning to improve network usage, which seemed to work fine. But now the problem still seems to happen....just much later....... After a while, when the game slows down...the simulated (dead reckoning) player won''t catch up with the real player anymore.... Once the game is really slowed down....if the players stop moving....the messages seem to catch up, the dead reckoning player catches up with the real player again and the game runs normal again...until someone starts moving again and it immediately slows down again........very strange....almost like some buffer would be full......which can''t be the case..as we''re not using any....unless it''s an internal buffer somewhere... The problem has to relate to some communication issue, as the problem never occured without the client-server structure. Did anyone ever notice any memory leaks in Directplay 9 using client/server structure? I don''t know if that might be a problem....i just can''t figure out the problem...... Any hints or suggestions will be greatly appreciated!!!! Thank you very much in advance!!! Daniel

Share this post


Link to post
Share on other sites
..just to test some more, I extracted the client/server part
from the game and put it into a small test application that
keeps sending messages to the server in 50ms interval and the
server forwards them back to the client....

...when I check check the taskmanager it seems the application''s
used memory grows continously.....and in the used methods, there''s no memory allocated.....

...any ideas?

Share this post


Link to post
Share on other sites
Server.GetSendQueueInformation(...)
Client.GetSendQueueInformation(...)

are your queue''s getting bogged up?

I had a problem like this with my FPS game(C#/mdx9), i spewed the send queue info out and found that just as my game started slowing... my server send queue was 10, 50, 100, 200, 500, 1000 messages backlogged.

Share this post


Link to post
Share on other sites
Smurfwow,

i once tried that a while ago....and it always showed 0.
But may I should try it and see what it shows when the game slows down....

How many messages did your game send when this happened?

Are you using Dead Reckoning?

...I will give it a try! Thanks!

Share this post


Link to post
Share on other sites
It seems we found the problem of the memory leak....

...although it''s C#...if you don''t dispose of all the NetworkPackets yourself, they somehow will not be released, not even by the GarbageCollector...

...so you either have to do ..using(NetworkPacket npak=...){ ...}

..or you have to dispose them manually after using them: npak.Dispose()

...interesting....

Share this post


Link to post
Share on other sites
Hey djc, have you tried manually calling C#''s garbage collection ?
System.GC.Collect ()
I wonder if that would work as well... if you get a chance to try that, could you please post your results?
I had some problems with C#''s garbage collection before as well so I manually called it.

Thanks,
Jason

Share this post


Link to post
Share on other sites
quote:
Original post by djc
...interesting....


Why? They propably contain unmanaged memory references. That they DO expose an IDispose interface means that they HAVE t obe disposed.

The GC should clear the memory, though, but this can take AGES until it is called.



Regards

Thomas Tomiczek
THONA Consulting Ltd.
(Microsoft MVP C#/.NET)

Share this post


Link to post
Share on other sites
JasonA,

I tried that...but not even the GC manages to free those resources.....as they seem to be unmanaged resources.
You have to call the Dispose method for those objects and then
the GC can free that memory....

thona,
yes, that''s why there is a dispose method...but I figured, the
dispose method would be executed in the destructor of the NetworkPacket object....which is not the case...one has to explicitely call it....

Share this post


Link to post
Share on other sites