<?xml version="1.0" encoding="UTF-8"?><rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
> <channel><title>Comments on: Measure memory consumption of creating object or executing functions in C#</title> <atom:link href="http://saftsack.fs.uni-bayreuth.de/~dun3/archives/measure-memory-consumption-creating-object-functions/102.html/feed" rel="self" type="application/rss+xml" /><link>http://saftsack.fs.uni-bayreuth.de/~dun3/archives/measure-memory-consumption-creating-object-functions/102.html</link> <description>This is a collection of interesting stuff that I found on the web or stuff I worked on at the time.</description> <lastBuildDate>Wed, 03 Mar 2010 14:57:47 +0000</lastBuildDate> <generator>http://wordpress.org/?v=2.9</generator> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <item><title>By: Tobias Hertkorn</title><link>http://saftsack.fs.uni-bayreuth.de/~dun3/archives/measure-memory-consumption-creating-object-functions/102.html/comment-page-1#comment-253097</link> <dc:creator>Tobias Hertkorn</dc:creator> <pubDate>Fri, 22 Aug 2008 10:42:58 +0000</pubDate> <guid
isPermaLink="false">http://saftsack.fs.uni-bayreuth.de/~dun3/archives/memory-consumption-of-creating-object-or-executing-functions-in-c/102.html#comment-253097</guid> <description>Hey Bruno,unfortunatelly there is little information out there about memory management in C# and no book I am aware of. Some links:http://blog.vuscode.com/malovicn/archive/2007/12/30/net-foundations-stack-and-heap.aspxhttp://www.bluebytesoftware.com/blog/http://msdn.microsoft.com/en-us/library/f144e03t.aspxOther than that... look at the mono runtime source code. ;)Cheers,
Tobi</description> <content:encoded><![CDATA[<p>Hey Bruno,</p><p>unfortunatelly there is little information out there about memory management in C# and no book I am aware of. Some links:</p><p><a
href="http://blog.vuscode.com/malovicn/archive/2007/12/30/net-foundations-stack-and-heap.aspx" rel="nofollow">http://blog.vuscode.com/malovicn/archive/2007/12/30/net-foundations-stack-and-heap.aspx</a></p><p><a
href="http://www.bluebytesoftware.com/blog/" rel="nofollow">http://www.bluebytesoftware.com/blog/</a></p><p><a
href="http://msdn.microsoft.com/en-us/library/f144e03t.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/f144e03t.aspx</a></p><p>Other than that&#8230; look at the mono runtime source code. <img
src='http://saftsack.fs.uni-bayreuth.de/~dun3/tsharp/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /></p><p>Cheers,<br
/> Tobi</p> ]]></content:encoded> </item> <item><title>By: Bruno</title><link>http://saftsack.fs.uni-bayreuth.de/~dun3/archives/measure-memory-consumption-creating-object-functions/102.html/comment-page-1#comment-252504</link> <dc:creator>Bruno</dc:creator> <pubDate>Thu, 21 Aug 2008 10:37:47 +0000</pubDate> <guid
isPermaLink="false">http://saftsack.fs.uni-bayreuth.de/~dun3/archives/memory-consumption-of-creating-object-or-executing-functions-in-c/102.html#comment-252504</guid> <description>Hello Tobias,I think the problem is gone now. Thanks for your answer. Could you please point me a good book in the matter?Thanks again,
Bruno</description> <content:encoded><![CDATA[<p>Hello Tobias,</p><p>I think the problem is gone now. Thanks for your answer. Could you please point me a good book in the matter?</p><p>Thanks again,<br
/> Bruno</p> ]]></content:encoded> </item> <item><title>By: Tobias Hertkorn</title><link>http://saftsack.fs.uni-bayreuth.de/~dun3/archives/measure-memory-consumption-creating-object-functions/102.html/comment-page-1#comment-251448</link> <dc:creator>Tobias Hertkorn</dc:creator> <pubDate>Tue, 19 Aug 2008 10:48:14 +0000</pubDate> <guid
isPermaLink="false">http://saftsack.fs.uni-bayreuth.de/~dun3/archives/memory-consumption-of-creating-object-or-executing-functions-in-c/102.html#comment-251448</guid> <description>Hey Bruon,could you email me a codesample? That would be easier for me to comment on, since I don&#039;t fully understand the circumstances where you see your varying memory sizes.Cheers.</description> <content:encoded><![CDATA[<p>Hey Bruon,</p><p>could you email me a codesample? That would be easier for me to comment on, since I don&#8217;t fully understand the circumstances where you see your varying memory sizes.</p><p>Cheers.</p> ]]></content:encoded> </item> <item><title>By: Bruno</title><link>http://saftsack.fs.uni-bayreuth.de/~dun3/archives/measure-memory-consumption-creating-object-functions/102.html/comment-page-1#comment-251080</link> <dc:creator>Bruno</dc:creator> <pubDate>Mon, 18 Aug 2008 15:00:54 +0000</pubDate> <guid
isPermaLink="false">http://saftsack.fs.uni-bayreuth.de/~dun3/archives/memory-consumption-of-creating-object-or-executing-functions-in-c/102.html#comment-251080</guid> <description>Hello,I&#039;m facing the same problem as Andy. I&#039;m looking for the piece of code that puts my memory in 500MB when I make a loop getting data from my database with NHibernate. I&#039;m using GC.TotalMemory(true) but it never uses the same amount of memory after I open a session.I hope you can help me with that.Thank you.</description> <content:encoded><![CDATA[<p>Hello,</p><p>I&#8217;m facing the same problem as Andy. I&#8217;m looking for the piece of code that puts my memory in 500MB when I make a loop getting data from my database with NHibernate. I&#8217;m using GC.TotalMemory(true) but it never uses the same amount of memory after I open a session.</p><p>I hope you can help me with that.</p><p>Thank you.</p> ]]></content:encoded> </item> <item><title>By: Tobias Hertkorn</title><link>http://saftsack.fs.uni-bayreuth.de/~dun3/archives/measure-memory-consumption-creating-object-functions/102.html/comment-page-1#comment-117182</link> <dc:creator>Tobias Hertkorn</dc:creator> <pubDate>Wed, 12 Dec 2007 14:49:30 +0000</pubDate> <guid
isPermaLink="false">http://saftsack.fs.uni-bayreuth.de/~dun3/archives/memory-consumption-of-creating-object-or-executing-functions-in-c/102.html#comment-117182</guid> <description>Hi Andy,please email me the complete code, since my comments seem to not like any less-than signs. I really have to fix that. :( sorry.But the good thing is: I think I know what happens - but the rest of your code is quite important for me finding out what exactly is happening. So please, send me the code...
You can find my email address on the &quot;about me&quot; page.Cheers,
Tobi</description> <content:encoded><![CDATA[<p>Hi Andy,</p><p>please email me the complete code, since my comments seem to not like any less-than signs. I really have to fix that. <img
src='http://saftsack.fs.uni-bayreuth.de/~dun3/tsharp/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> sorry.</p><p>But the good thing is: I think I know what happens &#8211; but the rest of your code is quite important for me finding out what exactly is happening. So please, send me the code&#8230;<br
/> You can find my email address on the &#8220;about me&#8221; page.</p><p>Cheers,<br
/> Tobi</p> ]]></content:encoded> </item> <item><title>By: Andy</title><link>http://saftsack.fs.uni-bayreuth.de/~dun3/archives/measure-memory-consumption-creating-object-functions/102.html/comment-page-1#comment-116695</link> <dc:creator>Andy</dc:creator> <pubDate>Tue, 11 Dec 2007 15:00:42 +0000</pubDate> <guid
isPermaLink="false">http://saftsack.fs.uni-bayreuth.de/~dun3/archives/memory-consumption-of-creating-object-or-executing-functions-in-c/102.html#comment-116695</guid> <description>sorry... tags cut off code. Was:byte[][] cache = new byte[1000][];
long[] memTotals = new long[1000];
for (int i = 0; i </description> <content:encoded><![CDATA[<p>sorry&#8230; tags cut off code. Was:</p><p>byte[][] cache = new byte[1000][];<br
/> long[] memTotals = new long[1000];<br
/> for (int i = 0; i</p> ]]></content:encoded> </item> <item><title>By: Andy</title><link>http://saftsack.fs.uni-bayreuth.de/~dun3/archives/measure-memory-consumption-creating-object-functions/102.html/comment-page-1#comment-116694</link> <dc:creator>Andy</dc:creator> <pubDate>Tue, 11 Dec 2007 14:59:04 +0000</pubDate> <guid
isPermaLink="false">http://saftsack.fs.uni-bayreuth.de/~dun3/archives/memory-consumption-of-creating-object-or-executing-functions-in-c/102.html#comment-116694</guid> <description>Hi Tobi and Anton,
Interesting stuff... I&#039;m having to do memory measurement for our performance unit tests. I&#039;m using GC.GetTotalMemory(false) to query the total memory allocated, but it&#039;s got an irritating problem - it does not accurately reflect the actual amount of memory allocated.
(I&#039;ve had the same problem, only worse, with the .NET performance counter &quot;# Bytes in all heaps&quot;).
(If I do a GC.GetTotalMemory(true) I get an accurate picture, but that&#039;s quite invasive, because it forces a GC).
If I store the results of GC.GetTotalMemory(false) in an array:
&lt;code&gt;
byte[][] cache = new byte[1000][];
long[] memTotals = new long[1000];
for (int i = 0; i
then dump out memTotals, apparent increases only occur once every 8 allocations - i.e. GC.GetTotalMemory(false) only seems to register an increase in ~8192 byte steps...
Given that this effect is (hopefully) deterministic, and tiny, I&#039;m still going to plough ahead and use GC.GetTotalMemory in my instrumentation, but it&#039;s a pain in the arse to know that it&#039;s not 100% reliable... is full profiling the only totally accurate way to do it, or am I talking crazy?</description> <content:encoded><![CDATA[<p>Hi Tobi and Anton,<br
/> Interesting stuff&#8230; I&#8217;m having to do memory measurement for our performance unit tests. I&#8217;m using GC.GetTotalMemory(false) to query the total memory allocated, but it&#8217;s got an irritating problem &#8211; it does not accurately reflect the actual amount of memory allocated.<br
/> (I&#8217;ve had the same problem, only worse, with the .NET performance counter &#8220;# Bytes in all heaps&#8221;).<br
/> (If I do a GC.GetTotalMemory(true) I get an accurate picture, but that&#8217;s quite invasive, because it forces a GC).<br
/> If I store the results of GC.GetTotalMemory(false) in an array:<br
/> <code><br
/> byte[][] cache = new byte[1000][];<br
/> long[] memTotals = new long[1000];<br
/> for (int i = 0; i<br
/> then dump out memTotals, apparent increases only occur once every 8 allocations - i.e. GC.GetTotalMemory(false) only seems to register an increase in ~8192 byte steps...<br
/> Given that this effect is (hopefully) deterministic, and tiny, I'm still going to plough ahead and use GC.GetTotalMemory in my instrumentation, but it's a pain in the arse to know that it's not 100% reliable... is full profiling the only totally accurate way to do it, or am I talking crazy?</code></p> ]]></content:encoded> </item> <item><title>By: Anton</title><link>http://saftsack.fs.uni-bayreuth.de/~dun3/archives/measure-memory-consumption-creating-object-functions/102.html/comment-page-1#comment-73716</link> <dc:creator>Anton</dc:creator> <pubDate>Mon, 27 Aug 2007 10:51:51 +0000</pubDate> <guid
isPermaLink="false">http://saftsack.fs.uni-bayreuth.de/~dun3/archives/memory-consumption-of-creating-object-or-executing-functions-in-c/102.html#comment-73716</guid> <description>Hi Tobi, Thanks first of all for this generous post!! I was anticipating a much worse approach I must say, it would have gone a little like this, To partition a section of memory and monitor the use of this section during processes. That would have been me, aproaching the bull from the wrong side :) not that I have the slightest idea of how to do that and would probably have lead to the creation of more memory &quot;bubbles&quot; (if one might say) if the use of memory exceeded the allocated bit. &lt;b&gt; Implementing your approach will probably mean that I will be maintaining my sanity! Thanks again! Anton&lt;/b&gt;</description> <content:encoded><![CDATA[<p>Hi Tobi, Thanks first of all for this generous post!! I was anticipating a much worse approach I must say, it would have gone a little like this, To partition a section of memory and monitor the use of this section during processes. That would have been me, aproaching the bull from the wrong side <img
src='http://saftsack.fs.uni-bayreuth.de/~dun3/tsharp/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> not that I have the slightest idea of how to do that and would probably have lead to the creation of more memory &#8220;bubbles&#8221; (if one might say) if the use of memory exceeded the allocated bit. <b> Implementing your approach will probably mean that I will be maintaining my sanity! Thanks again! Anton</b></p> ]]></content:encoded> </item> </channel> </rss>
<!-- This site's performance optimized by W3 Total Cache. Dramatically improve the speed and reliability of your blog!

Learn more about our WordPress Plugins: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (user agent is rejected)
Database Caching 1/14 queries in 0.265 seconds using disk

Served from: saftsack.fs.uni-bayreuth.de @ 2010-03-19 04:30:05 -->