Thread: [Quickfix-users] Memory Leak - Please help.
Brought to you by:
orenmnero
From: Sam S. <sa...@if...> - 2008-03-20 11:45:45
|
Hi, I am reasonably new to QuickFix and I have a problem. I have been asked to look at part of a C# application using the .Net QuickFixEngine library. My problem is that the application seems to have substantial memory leak. Looking at the application using a .Net memory profiler, it looks like a lot of QuickFix objects are hanging around in memory. It looks like the .Net code is releasing all references to the objects, but some unmanaged code is retaining a reference. Am I missing something obvious? Should the developers who wrote it have been calling a .Dispose method or delete or something on these objects? One major source of the leak seems to come from messages that are created by the unmanaged C++ library and passed into our managed code. When our managed code finishes with them they do not seem to get cleaned up. Please help. Sam Smith Developer / Infrastructure Intelligent Financial Systems 110 St Martin's Lane London WC2N 4BA Telephone 020 7379 7328 Fax 020 7379 7329 |
From: <or...@qu...> - 2008-04-04 16:37:48
|
<html><body><div>Oh, and FYI, AddMemoryPressure is only available if you are running .NET 2.0 or higher.</div> <div> </div> <div>--oren<BR><BR></div> <BLOCKQUOTE style="PADDING-LEFT: 8px; MARGIN-LEFT: 8px; BORDER-LEFT: blue 2px solid" webmail="1">-------- Original Message --------<BR>Subject: Re: [Quickfix-users] Memory Leak - Please help.<BR>From: <a href="mailto:or...@qu...">or...@qu...</a><BR>Date: Fri, April 04, 2008 11:17 am<BR>To: James P Michels III <jmi...@bl...><BR>Cc: <a href="mailto:Qui...@li...">Qui...@li...</a><BR><BR>QuickFIX Documentation: <A href="http://www.quickfixengine.org/quickfix/doc/html/index.html" target=_blank><a href="http://www.quickfixengine.org/quickfix/doc/html/index.html">http://www.quickfixengine.org/quickfix/doc/html/index.html</a></A><BR>QuickFIX Support: <A href="http://www.quickfixengine.org/services.html" target=_blank><a href="http://www.quickfixengine.org/services.html">http://www.quickfixengine.org/services.html</a></A><BR><BR> <HR> <DIV>Sort of. The problem is that memory allocated in C++ does not get reported to the garbage collector, so it doesn't realize how much memory has been allocated. With the code in subversion we add memory pressure to the GC for each allocated message which should help. If you get the latest from svn you can take advantage of it.</DIV> <DIV> </DIV> <DIV>--oren</DIV> <BLOCKQUOTE style="PADDING-LEFT: 8px; MARGIN-LEFT: 8px; BORDER-LEFT: blue 2px solid" webmail="1">-------- Original Message --------<BR>Subject: Re: [Quickfix-users] Memory Leak - Please help.<BR>From: James P Michels III <jmi...@bl...><BR>Date: Thu, April 03, 2008 3:31 pm<BR>To: <A onclick="Popup.composeWindow('pcompose.php?sendto=Quickfix-users%40lists.sourceforge.net');; return false;" href="mailto:Qui...@li..." target=_blank><a href="mailto:Qui...@li...">Qui...@li...</a></A><BR><BR>QuickFIX Documentation: <A href="http://www.quickfixengine.org/quickfix/doc/html/index.html" target=_blank><A href="http://www.quickfixengine.org/quickfix/doc/html/index.html" target=_blank><a href="http://www.quickfixengine.org/quickfix/doc/html/index.html">http://www.quickfixengine.org/quickfix/doc/html/index.html</a></A></A><BR>QuickFIX Support: <A href="http://www.quickfixengine.org/services.html" target=_blank><A href="http://www.quickfixengine.org/services.html" target=_blank><a href="http://www.quickfixengine.org/services.html">http://www.quickfixengine.org/services.html</a></A></A><BR><BR> <HR> -"We don't know when you are done with the message"<BR><BR>Isn't the whole point of a garbage collected runtime to deal with this problem?<BR><BR>OK, I get that its good form to call Dispose, but why is this required?<BR><BR>Doesn't Dispose get called when these objects are being garbage collected?<BR><BR><A class=moz-txt-link-abbreviated onclick="Popup.composeWindow('pcompose.php?sendto=oren%40quickfixengine.org');; return false;" href="mailto:or...@qu..." target=_blank _onclick="Popup.composeWindow('pcompose.php?sendto=oren%40quickfixengine.org');; return false;"><A onclick="Popup.composeWindow('pcompose.php?sendto=oren%40quickfixengine.org');; return false;" href="mailto:or...@qu..." target=_blank><a href="mailto:or...@qu...">or...@qu...</a></A></A> wrote: <BLOCKQUOTE cite=mid:200...@em... type="cite"><PRE wrap="">QuickFIX Documentation: <A class=moz-txt-link-freetext href="http://www.quickfixengine.org/quickfix/doc/html/index.html" target=_blank><A href="http://www.quickfixengine.org/quickfix/doc/html/index.html" target=_blank><a href="http://www.quickfixengine.org/quickfix/doc/html/index.html">http://www.quickfixengine.org/quickfix/doc/html/index.html</a></A></A> QuickFIX Support: <A class=moz-txt-link-freetext href="http://www.quickfixengine.org/services.html" target=_blank><A href="http://www.quickfixengine.org/services.html" target=_blank><a href="http://www.quickfixengine.org/services.html">http://www.quickfixengine.org/services.html</a></A></A> </PRE><BR> <HR width="90%" SIZE=4> <BR> <DIV>We don't know when you are done with the message. You need to call Dispose when you are finished with it.</DIV> <DIV> </DIV> <DIV>--oren</DIV> <BLOCKQUOTE style="PADDING-LEFT: 8px; MARGIN-LEFT: 8px; BORDER-LEFT: blue 2px solid" webmail="1">-------- Original Message --------<BR>Subject: [Quickfix-users] Memory Leak - Please help.<BR>From: "Sam Smith" <A class=moz-txt-link-rfc2396E onclick="Popup.composeWindow('pcompose.php?sendto=sam%40if5.com');; return false;" href="mailto:sa...@if..." target=_blank _onclick="Popup.composeWindow('pcompose.php?sendto=sam%40if5.com');; return false;"><sa...@if...></A><BR>Date: Thu, March 20, 2008 6:37 am<BR>To: <<A onclick="Popup.composeWindow('pcompose.php?sendto=quickfix-users%40lists.sourceforge');; return false;" href="mailto:qui...@li...urceforge" target=_blank _onclick="Popup.composeWindow('pcompose.php?sendto=quickfix-users%40lists.sourceforge');; return false;" moz-do-not-send="true"><A onclick="Popup.composeWindow('pcompose.php?sendto=quickfix-users%40lists.sourceforge');; return false;" href="mailto:qui...@li...urceforge" target=_blank><a href="mailto:qui...@li...urceforge">qui...@li...urceforge</a></A></A>.net><BR><BR>QuickFIX Documentation: <A href="http://www.quickfixengine.org/quickfix/doc/html/index.html" target=_blank moz-do-not-send="true"><A href="http://www.quickfixengine.org/quickfix/doc/html/index.html" target=_blank><A href="http://www.quickfixengine.org/quickfix/doc/html/index.html" target=_blank><a href="http://www.quickfixengine.org/quickfix/doc/html/index.html">http://www.quickfixengine.org/quickfix/doc/html/index.html</a></A>< /a></A><BR>QuickFIX Support: <A href="http://www.quickfixengine.org/services.html" target=_blank moz-do-not-send="true"><A href="http://www.quickfixengine.org/services.html" target=_blank><a href="http://www.quickfixengine.org/services.html">http://www.quickfixengine.org/services.html</a></A></A><BR><BR> <HR> <o:SmartTagType name="City" namespaceuri="urn:schemas-microsoft-com:office:smarttags"></o:SmartTagType><o:SmartTagType name="place" namespaceuri="urn:schemas-microsoft-com:office:smarttags"></o:SmartTagType> <STYLE> #wmMessage #wmMessage #wmMessage st1\:* {behavior:url(#default#ieooui) } </STYLE> <STYLE> #wmMessage #wmMessage #wmMessage /* Style Definitions */ p.MsoNormal, #wmMessage #wmMessage #wmMessage li.MsoNormal, #wmMessage #wmMessage #wmMessage div.MsoNormal {margin:0cm; margin-bottom:.0001pt; font-size:12.0pt; font-family:"Times New Roman";} #wmMessage #wmMessage #wmMessage a:link, #wmMessage #wmMessage #wmMessage span.MsoHyperlink {color:blue; text-decoration:underline;} #wmMessage #wmMessage #wmMessage a:visited, #wmMessage #wmMessage #wmMessage span.MsoHyperlinkFollowed {color:purple; text-decoration:underline;} #wmMessage #wmMessage #wmMessage span.EmailStyle17 {mso-style-type:personal-compose; font-family:Arial; color:windowtext;} #wmMessage #wmMessage #wmMessage @page Section1 {size:595.3pt 841.9pt; margin:72.0pt 90.0pt 72.0pt 90.0pt;} #wmMessage #wmMessage #wmMessage div.Section1 {page:Section1;} </STYLE> <DIV class=Section1> <DIV><FONT face=Arial size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">Hi,<o:p></o:p></SPAN></FONT></DIV> <DIV><FONT face=Arial size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"><o:p> </o:p></SPAN></FONT></DIV> <DIV><FONT face=Arial size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">I am reasonably new to QuickFix and I have a problem. I have been asked to look at part of a C# application using the .Net QuickFixEngine library.<o:p></o:p></SPAN></FONT></DIV> <DIV><FONT face=Arial size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"><o:p> </o:p></SPAN></FONT></DIV> <DIV><FONT face=Arial size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">My problem is that the application seems to have substantial memory leak.<o:p></o:p></SPAN></FONT></DIV> <DIV><FONT face=Arial size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"><o:p> </o:p></SPAN></FONT></DIV> <DIV><FONT face=Arial size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">Looking at the application using a .Net memory profiler, it looks like a lot of QuickFix objects are hanging around in memory. It looks like the .Net code is releasing all references to the objects, but some unmanaged code is retaining a reference.<o:p></o:p></SPAN></FONT></DIV> <DIV><FONT face=Arial size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"><o:p> </o:p></SPAN></FONT></DIV> <DIV><FONT face=Arial size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">Am I missing something obvious? Should the developers who wrote it have been calling a .Dispose method or delete or something on these objects? One major source of the leak seems to come from messages that are created by the unmanaged C++ library and passed into our managed code. When our managed code finishes with them they do not seem to get cleaned up.<o:p></o:p></SPAN></FONT></DIV> <DIV><FONT face=Arial size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"><o:p> </o:p></SPAN></FONT></DIV> <DIV><FONT face=Arial size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">Please help.<o:p></o:p></SPAN></FONT></DIV> <DIV><FONT face=Arial size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"><o:p> </o:p></SPAN></FONT></DIV> <DIV><STRONG><B><FONT face=Arial size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">Sam Smith</SPAN></FONT></B></STRONG><o:p></o:p></DIV> <DIV><FONT face=Arial size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">Developer / Infrastructure</SPAN></FONT><o:p></o:p></DIV> <DIV><FONT face=Arial size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">Intelligent Financial Systems</SPAN></FONT><o:p></o:p></DIV> <DIV><FONT face=Arial size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">110 <st1:place w:st="on">St Martin</st1:place>'s Lane<BR><st1:City w:st="on"><st1:place w:st="on">London</st1:place></st1:City><BR>WC2N 4BA</SPAN></FONT><o:p></o:p></DIV> <DIV><FONT face="Times New Roman" size=3><SPAN style="FONT-SIZE: 12pt"> <o:p></o:p></SPAN></FONT></DIV> <DIV><FONT face=Arial size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">Telephone 020 7379 7328</SPAN></FONT><o:p></o:p></DIV> <DIV><FONT face=Arial size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">Fax 020 7379 7329</SPAN></FONT><o:p></o:p></DIV> <DIV><FONT face="Times New Roman" size=3><SPAN style="FONT-SIZE: 12pt"><o:p> </o:p></SPAN></FONT></DIV></DIV> <HR> -------------------------------------------------------------------------<BR>This <A href="http://sf.net/" target=_blank moz-do-not-send="true"><A href="http://sf.net/" target=_blank><a href="http://SF.net">SF.net</a></A></A> email is sponsored by: Microsoft<BR>Defy all challenges. Microsoft(R) Visual Studio 2008.<BR><A href="http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/" target=_blank moz-do-not-send="true"><A href="http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/" target=_blank><a href="http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/">http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/</a></A></A> <HR> _______________________________________________<BR>Quickfix-users mailing list<BR><A href="#Compose" target=_self moz-do-not-send="true" __onclick="Popup.composeWindow('pcompose.php?sendto=Quickfix-users%40lists.sourceforge.net'); return false;"><A onclick="Popup.composeWindow('pcompose.php?sendto=Quickfix-users%40lists.sourceforge.net');; return false;" href="mailto:Qui...@li..." target=_blank><a href="mailto:Qui...@li...">Qui...@li...</a></A></A><BR><A href="https://lists.sourceforge.net/lists/listinfo/quickfix-users" target=_blank moz-do-not-send="true"><A href="https://lists.sourceforge.net/lists/listinfo/quickfix-users" target=_blank><a href="https://lists.sourceforge.net/lists/listinfo/quickfix-users">https://lists.sourceforge.net/lists/listinfo/quickfix-users</a></A></A><BR></BLOCKQUOTE><PRE wrap=""><HR width="90%" SIZE=4> ------------------------------------------------------------------------- This <A href="http://sf.net/" target=_blank><a href="http://SF.net">SF.net</a></A> email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. <A class=moz-txt-link-freetext href="http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/" target=_blank><A href="http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/" target=_blank><a href="http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/">http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/</a></A></A></PRE><PRE wrap=""><HR width="90%" SIZE=4> _______________________________________________ Quickfix-users mailing list <A class=moz-txt-link-abbreviated onclick="Popup.composeWindow('pcompose.php?sendto=Quickfix-users%40lists.sourceforge.net');; return false;" href="mailto:Qui...@li..." target=_blank _onclick="Popup.composeWindow('pcompose.php?sendto=Quickfix-users%40lists.sourceforge.net');; return false;"><A onclick="Popup.composeWindow('pcompose.php?sendto=Quickfix-users%40lists.sourceforge.net');; return false;" href="mailto:Qui...@li..." target=_blank><a href="mailto:Qui...@li...">Qui...@li...</a></A></A> <A class=moz-txt-link-freetext href="https://lists.sourceforge.net/lists/listinfo/quickfix-users" target=_blank><A href="https://lists.sourceforge.net/lists/listinfo/quickfix-users" target=_blank><a href="https://lists.sourceforge.net/lists/listinfo/quickfix-users">https://lists.sourceforge.net/lists/listinfo/quickfix-users</a></A></A> </PRE></BLOCKQUOTE><BR><PRE class=moz-signature cols="72"> </PRE> <HR> -------------------------------------------------------------------------<BR>Check out the new <A href="http://sourceforge.net/" target=_blank><a href="http://SourceForge.net">SourceForge.net</a></A> Marketplace.<BR>It's the best place to buy or sell services for<BR>just about anything Open Source.<BR><A href="http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace" target=_blank><A href="http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace" target=_blank><a href="http://ad.doubleclick.net/clk;164216239;13503038;w?">http://ad.doubleclick.net/clk;164216239;13503038;w?</a><A href="http://sf.net/marketplace" target=_blank><a href="http://sf.net/marketplace">http://sf.net/marketplace</a></A></A></A> <HR> _______________________________________________<BR>Quickfix-users mailing list<BR><A href="#Compose" target=_self _onclick="Popup.composeWindow('pcompose.php?sendto=Quickfix-users%40lists.sourceforge.net'); return false;">Quickfix-users<B></B>@lists.sourceforge.net</A><BR><A href="https://lists.sourceforge.net/lists/listinfo/quickfix-users" target=_blank><A href="https://lists.sourceforge.net/lists/listinfo/quickfix-users" target=_blank><a href="https://lists.sourceforge.net/lists/listinfo/quickfix-users">https://lists.sourceforge.net/lists/listinfo/quickfix-users</a></A></A><BR></BLOCKQUOTE> <HR> -------------------------------------------------------------------------<BR>Check out the new <a href="http://SourceForge.net">SourceForge.net</a> Marketplace.<BR>It's the best place to buy or sell services for<BR>just about anything Open Source.<BR><A href="http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace" target=_blank><a href="http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace">http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace</a></A> <HR> _______________________________________________<BR>Quickfix-users mailing list<BR><A onclick="Popup.composeWindow('pcompose.php?sendto=Quickfix-users%40lists.sourceforge.net'); return false;" href="#Compose">Quickfix-users<B></B>@lists.sourceforge.net</A><BR><A href="https://lists.sourceforge.net/lists/listinfo/quickfix-users" target=_blank><a href="https://lists.sourceforge.net/lists/listinfo/quickfix-users">https://lists.sourceforge.net/lists/listinfo/quickfix-users</a></A><BR></BLOCKQUOTE></body></html> |
From: Richard M. <rmi...@gm...> - 2008-04-09 21:18:14
|
Is there a stable release available with AddMemoryPressure enabled? It appears that it was added some 10 months ago. Does AddMemoryPressure remove the need to call Dispose on messages in general? If not, does this does really mean that a C# app is responsible for calling Dispose on any messages created by the message factory and messages is creates using the new operator? What if there are two separate references holding onto a message object and Dispose is call through one of the references; does it invalidate the other reference? Finally, if the app does need to call Dispose, what is your view of creating a wrapper C# class around messages that callas Dispose in its Finialize method as a work around? QuickFIX Documentation: http://www.quickfixengine.org/quickfix/doc/html/index.html QuickFIX Support: http://www.quickfixengine.org/services.html Oh, and FYI, AddMemoryPressure is only available if you are running .NET 2.0 or higher. --oren -- View this message in context: http://www.nabble.com/Memory-Leak---Please-help.-tp16177017p16597001.html Sent from the QuickFIX - User mailing list archive at Nabble.com. |