Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: Memory usage

From: Christophe:Coussement:mil:be at: 19-Oct-2005 10:46

Hi Ladislav, Thank you for your precisions, as accurate as usual :-)
> > > This is a special case not handled by the Garbage Collector as you > correctly found out. The GC "thinks", that you are going to need this > allocated memory when you allocated it intentionally. Therefore, it
will
> not "shrink" the space.
[[CC]] OK, I understand now
> >After a few try-and-errors, I found that first using a 'make on the
word
> >previously to the call to 'recycle, solves the problem: > > > > > my-string: none > > or > > my-string: copy "" > > or > > unset 'my-string > > would suffice. >
[[CC]] Actually, I did try those options, but without result, like illustrated (using /view 1.3):
>> stats
== 4183470
>> my-string: make string! 10000000
== ""
>> stats
== 13186209
>> unset 'my-string >> recycle stats
== 13186113 ;-> not freed
>> my-string: none
== none
>> recycle stats
== 13186145 ;-> not freed
>> my-string: copy ""
== ""
>> recycle stats
== 13186161 ;-> not freed
>> my-string: make none! none
== none
>> recycle stats
== 3185810 ;-> freed But I did perhaps misunderstand some part of your explanation?
> > > Right. RECYCLE call was not totally necessary, because it would happen > automatically sooner or later anyway. > > >You do not have to use a 'make none! To achieve this: a call to 'make > >string! "" or whatever does the job too. > The Garbage Collector is being called regularly anyway. If you call > RECYCLE too often, you are unnecessarily slowing down the interpreter.
[[CC]] Indeed, as obviously shown here:
>> rec: does [start: now/time/precise i: 0 loop 1000 [i: i + 1 recycle]
print now/time/precise - start]
>> rec
0:00:03.525
>> no-rec: does [start: now/time/precise i: 0 loop 1000 [i: i + 1] print
now/time/precise - start]
>> no-rec
0:00
> >You can find an interesting thread about this subject on the French > >REBOL forum: http://www.codeur.org/forum/message.php?ID_Sujet=2500 > > > > > I tried the URL and I got a C++ related page?
[[CC]] For some mysterious reasons (encoding perhaps?) some letters of my post are stripped out and replaced by weird things :-( (or is it Halloween approaching ?) The correct link is: http://www.codeur.org/forum/message.php?ID_Sujet=2500 ending with "ID_Sujet equals 2500".
> > > Yes, I think that those comments are helpful for somebody trying to > figure what is and what isn't collected by the GC. (Maybe we should
put
> it to a REBOL doc somewhere?)
[[CC]] OK, I will try to synthesize this thread into an article on the REBOL Documentation Project :-) ==christophe