algorithm - Preallocating large number of objects in C# -


this question exact duplicate of:

i implementing complex algorithm in c# uses large number of custom types.

one of main actions of algorithm creating new objects dynamically in runtime.

in order save many calls possible, aim preallocate number of different pools.

my algorithm use:

  • thousands of lists preallocated pool.
  • hundreds of structs preallocated pool.
  • hundreds of tree-like objects created in runtime, can contain large number of children.

i have read (here) c# gc optimized extremely fast allocations, know gc starts collecting when heap running low.

if algorithm make heap low gc start collecting, nothing because pools here stay, operation freeze application every time , can effect performance. should give idea of using pools , use newly allocated objects every time instead?

.net fast @ allocating objects , probs find things maybe immutable anyways. collect , if code referencing objects wont collected , pushed gen checked less often.

code profiling tools , code examples us.

this makes read

http://blogs.msdn.com/b/dotnet/archive/2012/07/20/the-net-framework-4-5-includes-new-garbage-collector-enhancements-for-client-and-server-apps.aspx


Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -