From: ptkwt@...1.aracnet.com (Phil Tomson) Date: 2001-12-19T23:46:19+09:00 Subject: [ruby-talk:28906] Re: memory management In article <9vloo0$1tlb$1@ns.felk.cvut.cz>, Petr Fischer wrote: >Hi, > >I am new in ruby language (I am new in languages based on garbage >collection). > >I use huge memory arrays, such as: > >a = [] >a[10000000] = "bla" // this allocates 40MB of memory on Win2000 >// ...some work with array > >And now, array "a" is unnecessary for me. > >a = [] > >But 40MB of memory is still allocated (in task manager on Win2000). > >How I free allocated memory? This will force it to be garbage collected: a = nil GC.start Generally, you don't need to worry about doing garbage collection manually, Ruby's GC is pretty efficient, but you don't always know when it will occur. So in a case like this where you've allocated such a large amount of memory it does make sense to call the garbage collector as soon as you don't need the object anymore. Phil