Visual C#, Large Arrays, and LOH Fragmentation. What is the accepted convention?

Posted by Gorchestopher H on Stack Overflow See other posts from Stack Overflow or by Gorchestopher H
Published on 2010-03-08T15:15:40Z Indexed on 2010/03/08 15:21 UTC
Read the original article Hit count: 624

Filed under:
|
|

I have an other active question HERE regarding some hopeless memory issues that possibly involve LOH Fragmentation among possibly other unknowns.

What my question now is, what is the accepted way of doing things? If my app needs to be done in Visual C#, and needs to deal with large arrays to the tune of int[4000000], how can I not be doomed by the garbage collector's refusal to deal with the LOH?

It would seem that I am forced to make any large arrays global, and never use the word "new" around any of them. So, I'm left with ungraceful global arrays with "maxindex" variables instead of neatly sized arrays that get passed around by functions.

I've always been told that this was bad practice. What alternative is there?

Is there some kind of function to the tune of System.GC.CollectLOH("Seriously") ? Are there possibly some way to outsource garbage collection to something other than System.GC?

Anyway, what are the generally accepted rules for dealing with large (>85Kb) variables?

© Stack Overflow or respective owner

Related posts about large

Related posts about arrays