Closed GoogleCodeExporter closed 9 years ago
Can you doublecheck your profiling? The TODO comment only regards to recycling
the NetSending object; not the entire message. This means the NetSending object
will be garbage collected and a for every send a new NetSending object have to
be created.
Ie. it does NOT mean that memory should grow continously, it just means the
garbage collector will have to work a little harder. The NetSending object is
quite small tho, so it shouldn't make a big difference unless you send a very
large number of messages.
Long living connection should not have any problems; they're just garbage
collected and overall memory consumption should be stable over time.
Original comment by lidg...@gmail.com
on 5 Sep 2010 at 9:56
I see.
I create a message using NetPeer.CreateMessage and then send it using
NetPeer.SendMessage .
The messages are sent very fast.
It seems that a data allocated for the message is not freed.
NetSending doesn't take a lot but it takes fair enough to be recycled.
Original comment by NN1436401@gmail.com
on 5 Sep 2010 at 10:52
I'm using .Net Memory Profiler (memprofiler.com) - I haven't been able to track
any leakage using the DurableServer/Client sample; which uses some different
delivery methods. How fast is your app growing over a large amount of time?
Original comment by lidg...@gmail.com
on 5 Sep 2010 at 11:53
I have found how to recreate the situation.
Take your samples: ManyServer, ManyClients.
In ManyClients write a lot of data instead of a small message.
http://code.google.com/p/lidgren-network-gen3/source/browse/trunk/Samples/ManyCl
ients/Client.cs
public partial class Client : Form
{
readonly byte[] SomeData = new byte[10 * 1000 * 1000];
...
#65 om.Write(SomeData);
}
Run ManyServer, Run ManyClients and create a client.
Follow TaskManager and you'll see memory usage increases.
Moreover, after you close the client window, you'll notice that you have 100%
CPU usage.
Original comment by NN1436401@gmail.com
on 6 Sep 2010 at 11:33
[deleted comment]
And set throttle in server to 0 or to some very big value :)
Original comment by NN1436401@gmail.com
on 6 Sep 2010 at 11:46
[deleted comment]
Now things are clear.
When I send a message it is put to the queue. The data is removed from the
queue once message is sent.
The problem that I put data too fast to the queue and sine the network is slow,
the message is queued thus increases memory consumption.
The solution is to not send messages too fast.
But there is no possibility to check how much data is queued per NetConnection.
One possibility is to add a new property to NetConnetionStatistics.
I attach a patch for this.
Original comment by NN1436401@gmail.com
on 6 Sep 2010 at 2:51
Attachments:
It can be slightly improved with introduction of event that notifies when the
data can be sent.
NetConfiguration can include MaxUnsentData and event to set.
NetConnection will check the unsentData when sending a message and then raise
the event when needed.
Original comment by NN1436401@gmail.com
on 6 Sep 2010 at 5:00
The event would be generated on the network thread; which is unlikely to be a
good place for the user to do stuff.
A property which calculates the amount of unsent data would be a good addition
tho - it would enable the application to decide for itself if it should add
more data to the queue.
Original comment by lidg...@gmail.com
on 7 Sep 2010 at 6:42
Added in rev 115; issue considered fixed.
Original comment by lidg...@gmail.com
on 7 Sep 2010 at 8:59
Original issue reported on code.google.com by
NN1436401@gmail.com
on 5 Sep 2010 at 9:17