Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.forth > #27168

Re: Reclaiming Allocated Memory

From anton@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups comp.lang.forth
Subject Re: Reclaiming Allocated Memory
Date 2013-12-06 17:42 +0000
Organization Institut fuer Computersprachen, Technische Universitaet Wien
Message-ID <2013Dec6.184255@mips.complang.tuwien.ac.at> (permalink)
References <5293458b$0$296$14726298@news.sunsite.dk> <2013Dec4.174638@mips.complang.tuwien.ac.at> <52a066dc$0$302$14726298@news.sunsite.dk> <2013Dec5.191410@mips.complang.tuwien.ac.at> <52a19fc6$0$302$14726298@news.sunsite.dk>

Show all headers | View raw


Doug Hoffman <glidedog@gmail.com> writes:
>On 12/5/13 1:14 PM, Anton Ertl wrote:
>> Doug Hoffman <glidedog@gmail.com> writes:
>
>> Unfortunately the use of such tools encourages
>> programmers to free everything at the end.
>
>Agreed.  Probably one should test and if that is a problem redesign so 
>more freeing is done sooner if possible.

If something can be freed earlier, yes it should be freed earlier.
But if it cannot, it should not be freed at the end of the process,

>e) RESIZE may not be not available without even more effort (extra 
>indirection?  manual copying of contents from old to new?).

Actually implementing RESIZE in my garbage collector should not be a
problem.  It's a bigger problem for the region-based allocator I am
working on and causes more program complexity than the rest combined.

However, does RESIZE fit with a GC?  I don't think so.  The point of
using a GC is that you don't need to keep track of how many things
point to an allocated place and where they are.  But if you use
RESIZE, you need to keep track of every address that points to your
RESIZEable thing; if you already do that, you can also use FREE for
that thing, and there is no point in using GC.

You can use ALLOCATE/RESIZE/FREE in the same program as my garbage
collector, so if you want to use RESIZE, my suggestion is to use it
with ALLOCATE and FREE, and use GC for things that do not resize.

Hmm, there would be one benefit from having RESIZE on garbage
collected memory: One could point from the resizable area to garbage
collected memory without declaring (and undeclaring) these pointers as
roots.  So maybe I will do it after all.

>> Which of these restrictions don't fit your programming style?
>
>a), b), and e) would be a problem for me.

a and b would require system-specific extensions, but all are
possible.  Maybe in a future revision.

>Yes.  Except a true region-based scheme has the advantage of fast 
>freeing compared to the above even after a large number of allocations, 
>if I understand correctly.

That's an implementation issue.

- anton
-- 
M. Anton Ertl  http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
     New standard: http://www.forth200x.org/forth200x.html
   EuroForth 2013: http://www.euroforth.org/ef13/

Back to comp.lang.forth | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Reclaiming Allocated Memory Doug Hoffman <glidedog@gmail.com> - 2013-11-25 07:41 -0500
  Re: Reclaiming Allocated Memory Paul Rubin <no.email@nospam.invalid> - 2013-11-25 07:04 -0800
    Re: Reclaiming Allocated Memory albert@spenarnc.xs4all.nl (Albert van der Horst) - 2013-11-25 16:16 +0000
      Re: Reclaiming Allocated Memory Paul Rubin <no.email@nospam.invalid> - 2013-11-25 09:03 -0800
        Re: Reclaiming Allocated Memory Doug Hoffman <glidedog@gmail.com> - 2013-11-26 06:30 -0500
          Re: Reclaiming Allocated Memory AKK <akk@nospam.org> - 2013-11-26 13:07 +0100
    Re: Reclaiming Allocated Memory Doug Hoffman <glidedog@gmail.com> - 2013-11-26 05:11 -0500
  Re: Reclaiming Allocated Memory anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-12-04 16:46 +0000
    Re: Reclaiming Allocated Memory Doug Hoffman <glidedog@gmail.com> - 2013-12-05 06:43 -0500
      Re: Reclaiming Allocated Memory Paul Rubin <no.email@nospam.invalid> - 2013-12-05 06:30 -0800
        Re: Reclaiming Allocated Memory albert@spenarnc.xs4all.nl (Albert van der Horst) - 2013-12-05 14:37 +0000
          Re: Reclaiming Allocated Memory Paul Rubin <no.email@nospam.invalid> - 2013-12-05 07:21 -0800
        Re: Reclaiming Allocated Memory Doug Hoffman <glidedog@gmail.com> - 2013-12-06 04:57 -0500
          Re: Reclaiming Allocated Memory Paul Rubin <no.email@nospam.invalid> - 2013-12-06 07:38 -0800
            Re: Reclaiming Allocated Memory Doug Hoffman <glidedog@gmail.com> - 2013-12-07 06:14 -0500
      Re: Reclaiming Allocated Memory anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-12-05 18:14 +0000
        Re: Reclaiming Allocated Memory Doug Hoffman <glidedog@gmail.com> - 2013-12-06 04:58 -0500
          Re: Reclaiming Allocated Memory Bernd Paysan <bernd.paysan@gmx.de> - 2013-12-06 17:30 +0100
            Re: Reclaiming Allocated Memory Doug Hoffman <glidedog@gmail.com> - 2013-12-07 05:59 -0500
              Re: Reclaiming Allocated Memory anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-12-07 11:57 +0000
                Re: Reclaiming Allocated Memory albert@spenarnc.xs4all.nl (Albert van der Horst) - 2013-12-07 17:48 +0000
                Re: Reclaiming Allocated Memory Bernd Paysan <bernd.paysan@gmx.de> - 2013-12-07 19:15 +0100
                Re: Reclaiming Allocated Memory anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-12-09 13:45 +0000
          Re: Reclaiming Allocated Memory anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-12-06 17:42 +0000

csiph-web