[R] how to free memory? (gc() doesn't work for me)

jim holtman jholtman at gmail.com
Sun Sep 5 21:58:43 CEST 2010


Depending on your operating system, the freed up memory might not be
returned to the operating system, but kept in the process space.

On Sat, Sep 4, 2010 at 10:17 PM, Hyunchul Kim <sundol at sfc.keio.ac.jp> wrote:
> Hi, all
>
> Thank you for your comments.
> I think that I misunderstood what gc() does because gc() is working as you
> posted.
>
> I posted my question because gc() doesn't reduce memory in use in a few
> system memory monitoring tools that I tested.
>
> Regards,
>
> Hyunchul
>
> On Sat, Sep 4, 2010 at 8:50 PM, jim holtman <jholtman at gmail.com> wrote:
>>
>> Seems to work for me:
>>
>> > x <- matrix(0,10000,10000)
>> > object.size(x)
>> 800000112 bytes
>> > gc()
>>            used  (Mb) gc trigger  (Mb)  max used  (Mb)
>> Ncells    174104   4.7     741108  19.8    741108  19.8
>> Vcells 101761938 776.4  113632405 867.0 102762450 784.1
>> > rm(x)
>> > gc()
>>          used (Mb) gc trigger  (Mb)  max used  (Mb)
>> Ncells  174202  4.7     741108  19.8    741108  19.8
>> Vcells 1761954 13.5   90905923 693.6 102762450 784.1
>>
>>
>> On Sat, Sep 4, 2010 at 12:46 AM, Hyunchul Kim
>> <hyunchul.kim.sfc at gmail.com> wrote:
>> > Hi, all
>> >
>> > I have a huge object that use almost all of available memory.
>> >
>> > R> rm(a_huge_object)
>> > R> gc()
>> >
>> > doesn't free memory and ?gc doesn't show anything.
>> >
>> > Are there any suggestion?
>> >
>> > Thanks in advance,
>> >
>> > Regards,
>> >
>> > Hyunchul
>> >
>> >        [[alternative HTML version deleted]]
>> >
>> > ______________________________________________
>> > R-help at r-project.org mailing list
>> > https://stat.ethz.ch/mailman/listinfo/r-help
>> > PLEASE do read the posting guide
>> > http://www.R-project.org/posting-guide.html
>> > and provide commented, minimal, self-contained, reproducible code.
>> >
>>
>>
>>
>> --
>> Jim Holtman
>> Cincinnati, OH
>> +1 513 646 9390
>>
>> What is the problem that you are trying to solve?
>
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?



More information about the R-help mailing list