On Wed, 23 May 2012 09:17:43 -0400, Don Clugston <d...@nospam.com> wrote:

On 23/05/12 05:22, Steven Schveighoffer wrote:
I have come across a dilemma.

Alex Rønne Petersen has a pull request changing some things in the GC to
pure. I think gc_collect() should be weak-pure, because it could
technically run on any memory allocation (which is already allowed in
pure functions), and it runs in a context that doesn't really affect
execution of the pure function.

So I think it should be able to be run inside a strong pure function.

I am almost certain it should not.

And I think this is quite important. A strongly pure function should be considered to have its own gc, and should not be able to collect any memory it did not allocate itself.

Well, given that the above is not implemented, what do you propose for the meantime?


Memory allocation from a pure function might trigger a gc cycle, but it would ONLY look at the memory allocated inside that pure function.


What if memory is tight, and the only way to get memory for this new allocation is to collect from the main heap? This seems an odd limitation, since strong-pure functions would not be affected by collecting in the main heap *at all*.

-Steve

Reply via email to