Re: Promptness of collection

Eliot Moss <[email protected]> Thu, 14 Mar 2013 14:58:41 -0400
Newsgroups gmane.comp.programming.garbage-collection.general
Message-ID <[email protected]>
On 3/14/2013 2:20 PM, Eric Freudenthal (personal) wrote:
> clearly I was too tired when I posted a incomprehensible note last night.  Let me try again:
>
> as observed, by Jon,
>
>   * variables can be recycled prior to end of scope at last reference, and
>   * recycling at that time can decrement a reference count to zero.
>
> I wonder about going further - cases where inter-procedural static analysis can make automatic
> memory management unnecessary for  some objects.  For example, when a constructor always returns the
> only reference to an object it creates, (or transitively, when a method always returns the only
> reference to an object) then the invoker could be responsible for its memory management - and
> deciding whether to obtain such objects' memory from
>
>   * a managed heap
>   * an unmanaged heap,
>   * or even the call stack
>
> I observe that this roughly corresponds to the memory management model used for posix syscalls.
>   Callers provide empty structs that the syscall fills in.

It can work for some cases, but once you move to the software design
concept of object *factories*, the specific kind of object ultimately
returned to the level where the allocation needs to happen cannot be
determined in advance.  The factory can choose any of various subclasses
of object to fulfill a request -- and maybe even an existing object,
which leads to other issues.  So, it has some applicability, but for
certain programming style won't change things much ...

Eliot Moss