Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I totally agree George Clingerman, the CLR on the 360 and WP7 have much slower garbage collectors than on the PC.</p> <p>First of all, I recommend you to learn how garbage collector works (it's no so hard).</p> <p>The basic steps are: 1. Verify 2. Profile 3. Locate 4. Fix</p> <p>Here you can find step by step instructions (basic) on how to do it with CLRProfiler <a href="http://spacedjase.com/post/2010/07/02/How-to-eliminate-frame-by-frame-Garbage-Generation-using-CLR-Profiler.aspx" rel="nofollow">http://spacedjase.com/post/2010/07/02/How-to-eliminate-frame-by-frame-Garbage-Generation-using-CLR-Profiler.aspx</a></p> <p>CLR Profiler enables you to look at the managed heap of a process and investigate the behavior of the garbage collector. Using the various views in the tool, you can obtain useful information about the execution, allocation, and memory consumption of your application. (Download <a href="http://www.microsoft.com/download/en/details.aspx?id=16273" rel="nofollow">http://www.microsoft.com/download/en/details.aspx?id=16273</a>)</p> <p>Here are the most useful links I found on the internet:</p> <ul> <li>How to tell if your Xbox garbage collection is too slow (http://blogs.msdn.com/b/shawnhar/archive/2007/06/29/how-to-tell-if-your-xbox-garbage-collection-is-too-slow.aspx)</li> <li>Twin paths to garbage collector nirvana (2 different aproachs to fight against slow GC) <a href="http://blogs.msdn.com/b/shawnhar/archive/2007/07/02/twin-paths-to-garbage-collector-nirvana.aspx" rel="nofollow">http://blogs.msdn.com/b/shawnhar/archive/2007/07/02/twin-paths-to-garbage-collector-nirvana.aspx</a></li> </ul> <p>And heres a summary of what I think are the most significant problems:</p> <p>Dont use linq Do not use LINQ. It looks cool. It makes your code shorter, simpler, and perhaps even easier to read. But LINQ queries can easily become a big source of trash. They’re fine in your startup code since you’re going to generate trash there anyway just by loading assets and preparing game resources. But don’t use it in Update, Draw, or any other method that gets called during gameplay.</p> <p>Displaying a string without triggering garbage collection Reply Quote Minimize use of ToString(). At a minimum it creates a string, which lives on the heap. See above about how to draw an int to the screen without generating any garbage. If you do need to use ToString, try to limit how often it’s called. If the string only changes every level, only generate it once at the beginning of the level. If it only changes when a certain value changes, only generate it when that value changes. Any limits you can put are worth it. The amount of time it takes to check a boolean condition is so small as to be almost nonexistent. You could probably fit tens and even hundreds of thousands of true/false checks in the amount of time it can take the GC to run on a complex heap. <a href="http://forums.create.msdn.com/forums/p/45512/273330.aspx#273330" rel="nofollow">http://forums.create.msdn.com/forums/p/45512/273330.aspx#273330</a> http://spacedjase.com/post/2010/09/16/Garbage-safe-number-to-string-conversion.aspx Beware of string formatting. It is hard to manipulate strings in .NET without causing allocations.</p> <p>Don't allocate memory (duh!) This is simple: do not call new on reference types. It is ok to new value types such as Matrix, Vector3, and Color, however. Any time you find yourself wanting to new a reference type, use an object pool to reuse existing instances instead. The Particle and Audio 3D samples oncreators.xna.com use this technique, and SwampThingTom blogged about a reusable pool collection. <a href="http://swampthingtom.blogspot.com/2007/06/generic-pool-collection-class.html" rel="nofollow">http://swampthingtom.blogspot.com/2007/06/generic-pool-collection-class.html</a> http://spacedjase.com/post/2010/07/02/Generic-Resource-Pool.aspx</p> <p>Don't use classes that allocate on your behalf When you add data to a collection class such as List or Dictionary, this may have to allocate memory to expand the collection. You can avoid that by using the collection constructor overloads which have explicit capacity parameters. Specify a capacity to preallocate as much memory as you will ever need for the maximum number of objects you intend to store in the collection.</p> <p>Don't make the CLR runtime allocate The CLR runtime allocates memory when boxing occurs. Avoid this like the plague! Boxing can happen for many reasons, some obvious, others less so: • If you assign a value type to an object variable, it gets boxed. • If you store value types in one of the old non-generic collection classes, they will be boxed. • Accessing value types via an interface causes them to be boxed. • If you use an enum type as a dictionary key, internal dictionary operations will cause boxing. You can avoid this by using integer keys, and casting your enum values to ints before adding them to the dictionary</p> <p>Greetings from Argentina HERNAN</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload