[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: GC + Java finalization
From: |
Maxime Devos |
Subject: |
Re: GC + Java finalization |
Date: |
Sat, 03 Jul 2021 19:14:45 +0200 |
User-agent: |
Evolution 3.34.2 |
Jonas Hahnfeld via Developers list for Guile, the GNU extensibility library
schreef op za 03-07-2021 om 14:05 [+0200]:
> Hi Guile devs,
>
Hi, I'm not really a Guile dev but I'll respond anyway.
> I'm hacking on GNU LilyPond and recently wondered if Guile could run
> without Java finalization that prevents collection of chains of
> unreachable objects.
Do you have an example where this is a problem?
I.e., did you encounter ‘chains of unreachable objects’ that were
uncollectable, and so, where?
> I found that the functionality is only needed once
> the first guardian is created, so it's possible to delay enabling the
> mode until then. This required some fixes to free functions that
> assumed dependent objects to be freed only later (see first two
> patches).
> The third patch delays ensuring Java finalization to scm_make_guardian,
> but doesn't disable it explicitly (it's on by default in bdwgc). This
> could now be done right after GC_INIT(), but it's not clear (at least
> to me) whether client applications actually rely it, so I think it's
> better if that's not done in Guile itself.
>
> Please consider applying, the fixes potentially also to stable-2.2.
>
> Thanks
> Jonas
I would need to look more closely at how ‘Java-style’ finalisation
works. Some comments anyway:
(first patch)
> * test-suite/standalone/test-smob-mark.c
> (init_smob_type): Correct size of smob type.
> (free_x): Clear smob data instead of local variable.
> (test_scm_smob_mark): Put smobs in array to ensure marking.
>
> - fprintf (stderr, "FAIL: SMOB mark function called for each SMOB\n");
> + // Print pointer so it cannot be collected before.
> + fprintf (stderr, "FAIL: SMOB mark function called for each SMOB (smobs
> = %p)\n", smobs);
> exit (EXIT_FAILURE);
Normally scm_remember_upto_here is used for that.
Also, I believe "/* */"-style comments are used customarily used in Guile
instead of "//"-style comments.
> static void
> init_smob_type ()
> {
> - x_tag = scm_make_smob_type ("x", sizeof (x_t));
> + x_tag = scm_make_smob_type ("x", sizeof (x_t *));
This change seems to be a fix independent of the ‘do we want Java-style
finalization’
question.
(third patch)
Note that guardians are used in (ice-9 popen).
They are also used by some guile libraries (e.g. guile-fibers),
so you can't use (ice-9 popen) or any library using guardians
if Java-style finalization is undesirable.
Greetings,
Maxime.
signature.asc
Description: This is a digitally signed message part