On Mon, Dec 1, 2014 at 5:24 PM, Andrea Ferretti <ferrettiand...@gmail.com>
wrote:

> Just to be sure: with-out-parameters takes care of freeing the
> underlying alien, right?
>
Yes, with-out-parameters allocates on the call stack, runs the quotation,
copies the data from the call stack to a new garbage collected object on
the heap, then the stack is cleaned up. So "utf8 alien>string" never sees
the original stack allocation, it sees a normal value on the heap that gets
garbage collected eventually.

Note however that using the call stack for large allocations is not a good
idea (the default call stack seems to be 512kb on 32bit and 1024kb on
64bit, can be modified with -callstack command line option)

Also, call stack overflows are checked when calling words
: foo ( n -- n ) [ 0 ] [ 1 - foo ] if-zero 1 + ;
100000 foo ! call stack overflow

But it's not checked in with-out-parameters:
: foo ( -- char-array ) { { char 200000000 } } [ drop ] with-out-parameters
;
foo ! memory protection fault, kind of correctly handled

but with bigger allocations is crashes the whole factor process.

Regards,
Jon
------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk
_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to