Not logged in. · Lost password · Register
Forum: MatriX RSS
Avatar
z668 #1
Member since Oct 2014 · 5 posts
Group memberships: Members
Show profile · Link to this post
Subject: Memory leak.
[Image: http://i2.5cm.ru/i/kmmF.png]
[Image: http://i2.5cm.ru/i/ShbD.png]
[Image: http://i2.5cm.ru/i/02tH.png]

                xmppClient.AutoInvoke = false;
                xmppClient.SetUsername(userName);
                xmppClient.Password = password;
                xmppClient.XmppDomain = xmppDomine;
                xmppClient.Transport = Transport.Socket;
                xmppClient.ResolveSrvRecords = false;

                xmppClient.OnAuthError += xmppClient_OnAuthError;
                xmppClient.OnError += xmppClient_OnError;
                xmppClient.OnRosterEnd += xmppClient_OnRosterEnd;

                try
                {
                    xmppClient.Open();
                }
                catch
                {
                    IsReady = true;
                }

                while (!IsReady)
                {
                    Thread.Sleep(1000);
                }

                xmppClient.OnAuthError -= xmppClient_OnAuthError;
                xmppClient.OnError -= xmppClient_OnError;
                xmppClient.OnRosterEnd -= xmppClient_OnRosterEnd;
                xmppClient.Close();
                xmppClient.Dispose();



private void xmppClient_OnRosterEnd(object sender, Matrix.EventArgs e)
{
 Message msg = new Matrix.Xmpp.Client.Message();

                    msg.Type = MessageType.chat;
                    msg.Nick = new Matrix.Xmpp.Nickname.Nick(GetNick()));
                    msg.To = JID;
                    msg.Body = GetTitle();
                    msg.XHtml = new Matrix.Xmpp.XHtmlIM.Html
                        {
                            Body = new Matrix.Xmpp.XHtmlIM.Body
                            {
                                InnerXHtml = "<p><b>" + GetText() + "</b></p>"
                            }
                        };

                    xmppClient.Send(msg);
               

                msg.SetValue(null);
                xmppClient.Close();
                xmppClient.Dispose();

                GC.Collect();

                IsReady = true;
This post was edited 2 times, last on 2014-10-27, 12:17 by z668.
Avatar
Alex #2
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Please elaborate your question, and let us know how exactly we can cause this.
I don't see how your simple code snippet an queue 100MB RAM. There were no memory leaks reported yet to MatriX. And when you found one then we need a sample to cause the issue on our end.
Which MatriX build for which platform and which profiling software are you using?

Alex
Avatar
z668 #3
Member since Oct 2014 · 5 posts
Group memberships: Members
Show profile · Link to this post
Hello, Alex.
Sorry for the delay in replying and sorry for bad english. Write through Google Translate.

Once again all is well tested. There is no memory leak. But there was another problem. The collapse of the library Matrix 1.6.0.1 (and 1.5.5.0 and last agsXMPP too).

OS: Win 8.1 Pro x64. VS 2013 Professional 2013
Version 12.0.31010.00 Update 4 RK

The collapse occurs after 20 minutes - 1 hour.

[Image: http://i2.5cm.ru/i/mByL.png]

[Image: http://i2.5cm.ru/i/St6W.png]
This post was edited 2 times, last on 2014-10-29, 20:43 by z668.
Avatar
z668 #4
Member since Oct 2014 · 5 posts
Group memberships: Members
Show profile · Link to this post
Workaround. But this is bad implementation.

<runtime>
<legacyUnhandledExceptionPolicy enabled="1"/>
</runtime>
Avatar
Alex #5
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
in the sample you attached you are sending 1000 messages in a row, without checking how fast your network and the delivery fo your messages it. MatriX is not designed for that, and this makes no sense.

Those 1000 messages probably fill up the queue and then the Windows Tls libraries crash somewhere. The stacktrace you posted is in the .NET framework, I see no reference to MatriX there.

Summary: don't send a huge amount of messages in a loop which fills up the queue. Send them in smaller packets, eg. 10, and wait until they are delivered and then continue with the next messages.

Alex
Avatar
z668 #6
Member since Oct 2014 · 5 posts
Group memberships: Members
Show profile · Link to this post
Thank you, Alex.
How can I know that 10 messages delivered?
Avatar
Alex #7
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
there are many ways.

some suggestions:
XEP-0184: Message Delivery Receipts
http://xmpp.org/extensions/xep-0184.html

Acks in XEP-0198: Stream Management
http://xmpp.org/extensions/xep-0198.html

send an XMPP ping and the last packet, when the ping return then the previous messages were delivered as well. Because a requirement of XMPP is in order delivery:
http://xmpp.org/extensions/xep-0199.html

You can also request a receipt only on your last packet.

Alex
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Forum: MatriX RSS