Re: [Gc] How to do enable gc of prolog programs using bdw-gc
Bruce Hoult <[email protected]>
| Newsgroups | gmane.comp.programming.garbage-collection.boehmgc |
|---|---|
| Message-ID | <CAMU+Ekzjp1u5eQgtKbFmYDho=VXTNHW0oJ9JTNd3p_PLGyq8vw@mail.gmail.com> |
On Thu, May 8, 2014 at 7:31 AM, Stefan Israelsson Tampe < [email protected]> wrote: > Wingo or anyone else. In a finalizer, if the object should not be gc'ed > what do I need to do? just leave it? > and in the case when it should be gc'ed what do I do scm_gc_free? > If an object should not be gc'd then how did you get into the finalizer for it? In bdwgc objects with finalizers are not actually collected or overwritten until the GC after the GC in which the finalizer is run. Therefore, technically, the finalizer can prevent the object from being collected by putting a pointer to the object into a global or another gc'able object. But if you still wanted the object then why didn't you already have a reference to it somewhere? If there is no reference to it then it can't take any further part in the computation. Unless maybe you have a reference to it from somewhere the GC doesn't look, such as an object allocated using malloc instead of GC_malloc. I've never seen a situation in which resurrection-by-finalizer was the best solution. I'd be curious to see one. And, remember that by the time the finalizer is run the finalizer has been de-registered, so the resurrected object no longer has a finalizer. In general, very very few objects should have finalizers. Typically the reason is that you need to release some external, non-gc'd resource e.g. close a file or delete an object allocated using some foreign API from a library. Things like that. _______________________________________________ bdwgc mailing list [email protected] https://lists.opendylan.org/mailman/listinfo/bdwgc