﻿<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>Ayende @ Rahien</title><link>http://ayende.com</link><description>Ayende @ Rahien</description><copyright>Copyright (C) Ayende Rahien  2004 - 2021 (c) 2026</copyright><ttl>60</ttl><item><title>Kevin Dente commented on Patterns for reducing memory usage</title><description>Sure, but AddMemoryPressure assumes a priori knowledge of the size of the objects. Not very practical in the general case. It's one of the nasty flaws in the whole COM interop story.
</description><link>http://ayende.com/4347/patterns-for-reducing-memory-usage#comment8</link><guid>http://ayende.com/4347/patterns-for-reducing-memory-usage#comment8</guid><pubDate>Tue, 05 Jan 2010 18:52:40 GMT</pubDate></item><item><title>Ayende Rahien commented on Patterns for reducing memory usage</title><description>Kevin,
  
That is why you have GC.AddMemoryPressure
</description><link>http://ayende.com/4347/patterns-for-reducing-memory-usage#comment7</link><guid>http://ayende.com/4347/patterns-for-reducing-memory-usage#comment7</guid><pubDate>Tue, 05 Jan 2010 18:43:49 GMT</pubDate></item><item><title>Kevin Dente commented on Patterns for reducing memory usage</title><description>Another fun one is the scenario with small managed objects managing large unmanaged objects. COM interop is the primary example. When you have large COM objects being used from managed code, the garbage collector isn't aware of that memory usage and doesn't trigger garbage collection. 
</description><link>http://ayende.com/4347/patterns-for-reducing-memory-usage#comment6</link><guid>http://ayende.com/4347/patterns-for-reducing-memory-usage#comment6</guid><pubDate>Tue, 05 Jan 2010 17:35:50 GMT</pubDate></item><item><title>Jon commented on Patterns for reducing memory usage</title><description>Minor code fix: "results" should be "result" in your garbage spewer example.  Threw me off for a second.
</description><link>http://ayende.com/4347/patterns-for-reducing-memory-usage#comment5</link><guid>http://ayende.com/4347/patterns-for-reducing-memory-usage#comment5</guid><pubDate>Mon, 04 Jan 2010 20:11:16 GMT</pubDate></item><item><title>Ayende Rahien commented on Patterns for reducing memory usage</title><description>Fero,
  
I am not really worried about that particular example, I am talking about the general case.
</description><link>http://ayende.com/4347/patterns-for-reducing-memory-usage#comment4</link><guid>http://ayende.com/4347/patterns-for-reducing-memory-usage#comment4</guid><pubDate>Sun, 03 Jan 2010 09:06:40 GMT</pubDate></item><item><title>Fero commented on Patterns for reducing memory usage</title><description>Garbage spewers (quick fix)
  
  
public string Concat(string[] items)
  
            {
  
                StringBuilder sb = new StringBuilder();
  
                foreach (var item in items)
  
                {
  
                    sb.Append(item);
  
                }
  
                return sb.ToString(); 
  
            }
</description><link>http://ayende.com/4347/patterns-for-reducing-memory-usage#comment3</link><guid>http://ayende.com/4347/patterns-for-reducing-memory-usage#comment3</guid><pubDate>Sun, 03 Jan 2010 08:59:56 GMT</pubDate></item><item><title>Ayende Rahien commented on Patterns for reducing memory usage</title><description>Pet,
  
String is immutable, as such, a new string is generated every time we concat the string.
</description><link>http://ayende.com/4347/patterns-for-reducing-memory-usage#comment2</link><guid>http://ayende.com/4347/patterns-for-reducing-memory-usage#comment2</guid><pubDate>Sun, 03 Jan 2010 06:43:25 GMT</pubDate></item><item><title>Pet commented on Patterns for reducing memory usage</title><description>Really interesting article.
  
But, I did some test and found that Code sample above posted doesn't create garbage in the foreach loop. 
  
string gets finalized only when we return from the function.
  
  
Please help with this example. 
</description><link>http://ayende.com/4347/patterns-for-reducing-memory-usage#comment1</link><guid>http://ayende.com/4347/patterns-for-reducing-memory-usage#comment1</guid><pubDate>Sun, 03 Jan 2010 05:37:11 GMT</pubDate></item></channel></rss>