[Mono-list] How do I force a garbage collection / free a heap
Chris Howie
cdhowie at gmail.com
Mon Nov 16 05:31:34 EST 2009
And note that GC.Collect() is only a recommendation to the runtime
that now might be a good time to run the GC. The runtime is free to
ignore this call if it so chooses.
(PS Sorry about the top-post. Gmail mobile is not the best for lists.)
On 11/15/09, Michael Hutchinson <m.j.hutchinson at gmail.com> wrote:
> On Sun, Nov 15, 2009 at 7:04 PM, Mike Christensen <mike at kitchenpc.com>
> wrote:
>> Hi all -
>>
>> I have a program that generates some results, but in order to do so it
>> must load a whole lotta stuff into memory for calculations. When this
>> is done, I only need the results and not the data in memory. This
>> data might be several hundred megs on the heap or more.
>>
>> When I'm done, I want to "free" this data and not have it sit around
>> and slow down stuff. Is there a way to force a GC cycle or just say
>> "delete these objects"? Is there a better design for this sort of
>> thing (like can I create my own heap and just release the whole thing
>> at once?) Also, I'm aware that GC will freeze all threads while it
>> works, which is okay since I only do this when the application starts
>> and I don't mind if the start-up costs are slow (since it's a web
>> site)..
>>
>> Any pointers would be great!
>
> You can use GC.Collect () to force a collection. Generally it's
> advised not to call GC.Collect, because it's best to let the garbage
> collector handle its scheduling, but it sounds like your use case is
> okay.
>
> --
> Michael Hutchinson
> http://mjhutchinson.com
> _______________________________________________
> Mono-list maillist - Mono-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
>
--
Chris Howie
http://www.chrishowie.com
http://en.wikipedia.org/wiki/User:Crazycomputers
More information about the Mono-list
mailing list