Prev: kbs 0.4 binaries
Next: 16-bit greyscale photos in Tk
From: pmarin on 26 Jan 2010 08:21 Hi all. Tcl "never" release the memory. Try the following code several times (source the script several times in the same shell), the first time It takes the memory and the other times I will not take more memory but It "never" will release the memory. Tested in Linus 2.6.28.4 http://gist.github.com/286826
From: Robert Heller on 26 Jan 2010 08:46 At Tue, 26 Jan 2010 05:21:12 -0800 (PST) pmarin <pacogeek(a)gmail.com> wrote: > > Hi all. > > Tcl "never" release the memory. Try the following code several times > (source the script several times in the same shell), the first time It > takes the memory and the other times I will not take more memory but > It "never" will release the memory. > > Tested in Linus 2.6.28.4 > http://gist.github.com/286826 > If you are looking at top (or similar process memory tool), this is *normal* for most C/UNIX programs: ALL UNIX-style C programs that use malloc() (or UNIX-style C++ programs that use operator new) maintain a heap: initially the heap is empty and the first time malloc (new) is called, the brk() system call is used to extend the process's memory and the heap is started. When objects are free()ed (deleted), the memory is placed on the heap and future malloc()s (news) use the memory off the heap. At no point is the memory returned to the O/S until process termination. -- Robert Heller -- 978-544-6933 Deepwoods Software -- Download the Model Railroad System http://www.deepsoft.com/ -- Binaries for Linux and MS-Windows heller(a)deepsoft.com -- http://www.deepsoft.com/ModelRailroadSystem/
From: Georgios Petasis on 26 Jan 2010 08:59 στις 26/1/2010 15:21, O/H pmarin έγραψε: > Hi all. > > Tcl "never" release the memory. Try the following code several times > (source the script several times in the same shell), the first time It > takes the memory and the other times I will not take more memory but > It "never" will release the memory. > > Tested in Linus 2.6.28.4 > http://gist.github.com/286826 This is true. Tcl never releases the memory it allocates fro tcl objects back to the operating system. Once your script has created a large number of tcl objects simultaneously, the memory will be kept in the process until the process has finished. This feature has beem present in tcl for many years now (10+). It avoids memory fragmentation that can be caused by allocating/freeing many small fragments (like a tcl object). The behaviour is similar to: Whan an object is needed, it is checked if it can be created in existing allocated memory. If not, a larger piece of memory (that can hold N objects) is allocated, inside which the object is created and returned. The rest of the memory can be used for other objects. George
From: pmarin on 26 Jan 2010 09:03 On Jan 26, 2:46 pm, Robert Heller <hel...(a)deepsoft.com> wrote: > At Tue, 26 Jan 2010 05:21:12 -0800 (PST) pmarin <pacog...(a)gmail.com> wrote: > > > > > Hi all. > > > Tcl "never" release the memory. Try the following code several times > > (source the script several times in the same shell), the first time It > > takes the memory and the other times I will not take more memory but > > It "never" will release the memory. > > > Tested in Linus 2.6.28.4 > >http://gist.github.com/286826 > > If you are looking at top (or similar process memory tool), this is > *normal* for most C/UNIX programs: ALL UNIX-style C programs that use > malloc() (or UNIX-style C++ programs that use operator new) maintain a > heap: initially the heap is empty and the first time malloc (new) is > called, the brk() system call is used to extend the process's memory > and the heap is started. When objects are free()ed (deleted), the > memory is placed on the heap and future malloc()s (news) use the memory > off the heap. At no point is the memory returned to the O/S until > process termination. > > -- > Robert Heller -- 978-544-6933 > Deepwoods Software -- Download the Model Railroad Systemhttp://www.deepsoft.com/ -- Binaries for Linux and MS-Windows > hel...(a)deepsoft.com --http://www.deepsoft.com/ModelRailroadSystem/ Is there any reason for this behaviour?
From: pmarin on 26 Jan 2010 09:07
On Jan 26, 3:03 pm, pmarin <pacog...(a)gmail.com> wrote: > On Jan 26, 2:46 pm, Robert Heller <hel...(a)deepsoft.com> wrote: > > > > > At Tue, 26 Jan 2010 05:21:12 -0800 (PST) pmarin <pacog...(a)gmail.com> wrote: > > > > Hi all. > > > > Tcl "never" release the memory. Try the following code several times > > > (source the script several times in the same shell), the first time It > > > takes the memory and the other times I will not take more memory but > > > It "never" will release the memory. > > > > Tested in Linus 2.6.28.4 > > >http://gist.github.com/286826 > > > If you are looking at top (or similar process memory tool), this is > > *normal* for most C/UNIX programs: ALL UNIX-style C programs that use > > malloc() (or UNIX-style C++ programs that use operator new) maintain a > > heap: initially the heap is empty and the first time malloc (new) is > > called, the brk() system call is used to extend the process's memory > > and the heap is started. When objects are free()ed (deleted), the > > memory is placed on the heap and future malloc()s (news) use the memory > > off the heap. At no point is the memory returned to the O/S until > > process termination. > > > -- > > Robert Heller -- 978-544-6933 > > Deepwoods Software -- Download the Model Railroad Systemhttp://www.deepsoft.com/ -- Binaries for Linux and MS-Windows > > hel...(a)deepsoft.com --http://www.deepsoft.com/ModelRailroadSystem/ > > Is there any reason for this behaviour? Sorry I have not read the George comment. Thanks. all |