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

Re: SOS. No garbage-collection on exit!



Hello Matthew,

thank you very much for the swift response.

-------------------
> Quoting Sebastian H Seidel:
> > My finalizers are ignored. The current-custodian is not called.
> > What can I do to free my data on exit?
> 
> In v200 (maybe earlier, I forget), you can call
> 
>   scheme_add_atexit_closer()
> 
> to install a procedure that is called at exit on all custodian-
> managed objects. 

This procedure is what i need but it's not in v103.

> You don't need to bother with it merely to release
> memory, though.

Not entirely true because the extension serves as a means for
operating on matrices in the matlab-environment, from within MzScheme.
Each Matlab-matrix is linked with a Scheme_Object. If the
Scheme_Object is bound to a local variable, e.g. inside a let-form,
the corresponding matlab-matrix will only be valid inside the
let-form, too ... although that is not entirely true, because
garbage-collection never happens instantly ... but I did have no
better idea, do you?
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).

> > PS: What happens to the other data? Is MzScheme slowly drowning my
> > computer with unfreed data if only I happen to start and exit it
> > often enough?
> 
> No modern OS fails to release the memory associated with a process
> that terminates --- where "modern" in this case can even be
> stretched to include Mac OS 7.
> For the more broken variants of Windows and Mac OS, there are some
> resources that really must be released explicitly. MzScheme/MrEd 
> uses something like scheme_add_atexit_closer() to release those 
> resources.
> 
> Matthew
> 

Thanks, now I understand that garbage-collection on exit is not done
simply because it is not necessary. For me it would make things easier
but an exit-hook would be fine, too. Is there any specific reason for
not providing one, save one that is restricted to work on
custodian-bound data?

Greetings,
Sebastian

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 ... all the time I'm angious not to do
something wrong because the program might fail at a point where I'll
not even be able to trace back the error. The program must be able to
run for some days without failure and intervention on a "more broken
variant" of operating system, namely Windows98. Alas ... where could I
start reading?