Coffeehouse Post

Single Post Permalink

View Thread: Patrick Dussud interview next week: Questions?
  • User profile image
    Minh

    DoomBringer wrote:
    
    Minh wrote:
    

    Littleguru wrote:
    - Why isn't it possible to force the GC to do a collect. I mean GC.Collect() just signalizes that a collect is required, but the GC could decide to do not. Why has this been implemented in that way?


    If this is indeed true, can't we have a GC.Collect(bool meanIt); ?


    Probably because the GC knows more about current memory than the developer does 99% of the time.  Forcing a GC when there are only a few dozen objects that need cleaning up is a bad idea.  GC collection is a high overhead operation and calling it arbitrarily is bad practice nearly all of the time.

    I don't agree. The end-result for a GC.Collect is ALWAYS a less fragmented memory space. So there must be a penalty if they don't want us to do this all the time.

    I'm guessing that penalty is the runtime becomes unresponsive for a while. In a game, you'd do anything not to have the GC runs its Collect routine in the middle of a game, and if you could, you should minimize that chance when it's OK to run at a lower framerate, say, the user is shopping for a new sword with his loot.

    Now, the crazy desktop app programmer who thinks he knows better by running GC.Collect everytime the user click on a button will be punished by having his app run like crap --- but at least that's a positive feedback for him to remove that GC.Collect.

    If you can't deterministically run GC.Collect() as a game programmer, you're punished by a run-time that think it knows better.