Don napisał:

> LEAKY FUNCTIONS
> 
> Define a 'leaky' pure function as a pure function which can return
> heap-allocated memory to the caller, ie, where the return value or a
> parameter passed by reference has at least one pointer or reference
> type. This can be determined simply by inspecting the signature. (Note
> that the function does not need to be immutably pure).
> 
> The interesting thing is that heap allocation inside non-leaky pure
> functions behaves like stack allocation. When you return from that
> function, *all* those variables are unreachable, and can be discarded en 
> masse. Here's an idea of how to exploit this.
> 
> THE PURE HEAP
> 
> [snip]

I'm far from being a GC expert but I think Java having identified such cases 
with escape analysis just puts locally allocated objects on the stack.

Couldn't we too? Your mark & release "pure heap" scheme looks alright but this 
seems simpler.

The notion of "non-leaky" functions can be useful either way.

-- 
Tomek

Reply via email to