From: kjana@...4lab.to (YANAGAWA Kazuhisa) Date: 2001-12-20T20:59:07+09:00 Subject: [ruby-talk:29098] Re: memory management In message ptkwt@shell1.aracnet.com writes: > >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. Additionally, it may be an item of the C FAQ: free()ing a malloc()ed memory block does not means the block to be returned to underlying OS. I'm not sure Windows task manager shows what as allocated memory, but likely it is memory usage of the process. Since memory allocation library can have a pool of freed()ed memory for future use, the value can never shrink down. Anyway it becomes serious problem only when many such processes running concurrently. Because free()ed memories are recycled in that process, trashed objects don't affect real memory usage of the program. Namely process size will be saturated at some point, and it depends maximum sum of size of living objects. -- kjana@dm4lab.to December 20, 2001 First come, first served.