[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: SOS. No garbage-collection on exit!



Hello again,


> I'm still a bit puzzled, because the default `exit' calls C exit(),
> which means that some process somewhere is terminated in your
current
> setup.

... which process do you mean? 
- Matlab is surely running afterwards because I can enter the
command-window and type 'testvar' which is the name of the variable
that I did send from MzScheme to Matlab before exiting MzScheme and it
gives me the string "Sorry, I'm still here." which was the value I
gave it in the Scheme-Environment.
- MzScheme is surely closed because I called (exit).


I've tried using scheme_exit, like so:

void my_exit_function (int i) 
{ 
  scheme_close_managed (extn_master_custodian);
}
scheme_exit = my_exit_function;


and got this compiler warning:

Anzahl der Dereferenzierungen bei 'int' und 'void (__cdecl *)(int )'
unterschiedlich.

which means that scheme_exit is an 'int', which puzzled me and it did
not work, too. "Inside PLT Scheme" says 'scheme_exit' is available
when MzScheme is embedded ... maybe meaning "only when MzScheme is
embedded" ... but then: why should it be declared at all and as 'int'
and not as 'void*'?
No matter what ... I do not intend to waste your time with this
trivial matter. MzScheme is a fantastic program and I will wait till
v200 is out and then I'll port the whole thing and use the
scheme_add_atexit_closer() which anyway - by creating a strawman
custodian - might be abused to do anything i want.
For now, I must open and close process-interaction explicitly in my
scheme-program and assign some additional custodians ... this is not
too much a drawback and as well already implemented. I only thought it
could be done a little smarter.

Thank you,
Sebastian



------------------
> Quoting Sebastian H Seidel:
> > When MzScheme exits, I would like to clear the instances of all
> > formerly globally defined variables out of the Matlab-environment
and
> > it would be sooo easy if there was an exit-hook! Simply calling
> > (collect-garbage).
> 
> I'm still a bit puzzled, because the default `exit' calls C exit(),
> which means that some process somewhere is terminated in your
current
> setup.
> 
> But, in any case, the hook you want exists: scheme_exit is a global
> variable in C that you can redirect to your own exit function.
> 
> > PS: I would like to learn about the behaviour of the
> > MzScheme-garbage-collector because I'm rather unsure how to
interact
> > with it. Many functions that have to do with garbage-collection
are
> > not at all clear to me ...
> 
> I'm not sure where to point you at this time other than Inside
MzScheme
> (and this mailing list for specific questions).
> 
> Matthew
> 
>