[Gc] Question: Can finalizers be used together with typed memory allocation?

Alexander Doronin alexanderdoronin at pdc.spb.su
Thu Sep 19 06:03:37 PDT 2013

Dear Mr. Boehm!

We are using your Garbage Collector for Visual Prolog under Windows for
many years.
Now we are going to use the typed memory allocation with finalizers, but we
have some doubts about it.

We have tried to allocate typed memory by function
GC_malloc_explicitly_typed and register our finalizer by
GC_REGISTER_FINALIZER_NO_ORDER, but then we are recieving this error here:

GC_API void GC_CALL GC_debug_register_finalizer_no_order
                                    (void * obj, GC_finalization_proc fn,
                                     void * cd, GC_finalization_proc *ofn,
                                     void * *ocd)
    GC_finalization_proc my_old_fn = OFN_UNSET;
    void * my_old_cd;
    ptr_t base = GC_base(obj);
    if (0 == base) {
        /* We won't collect it, hence finalizer wouldn't be run. */
        if (ocd) *ocd = 0;
        if (ofn) *ofn = 0;
    if ((ptr_t)obj - base != sizeof(oh)) {
*        GC_err_printf(*
*          "GC_debug_register_finalizer_no_order called with "*
*          "non-base-pointer %p\n",*
*          obj);*

Could you, please, tell us whether it's possible to use typed allocation
with finalizers or not?

Kind regards, Alexander Doronin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://napali.hpl.hp.com/pipermail/gc/attachments/20130919/38e99f49/attachment.htm

More information about the Gc mailing list