l...@gnu.org (Ludovic Courtès) skribis:

> On 2.2.2, the heap grows indefinitely (though logarithmically).  It’s
> not deterministic though: sometimes the heap size stabilizes in the
> 140–300 MiB range, and sometimes it keeps growing endlessly even though
> the table size reaches a maxium at 7,190,537 entries.

Below is a simple reproducer in C that I’ve also reported at
<https://github.com/ivmai/bdwgc/issues/182>:

--8<---------------cut here---------------start------------->8---
#define GC_DEBUG 1
#include <gc.h>
#include <stdlib.h>
#include <stdio.h>

int
main ()
{
  GC_INIT ();

  while (1)
    {
      unsigned int count = 777 * (random () % 1000);
      void **p = GC_MALLOC_ATOMIC (count * sizeof *p);

      for (unsigned int i = 0; i < count; i++)
        {
          void *key = GC_MALLOC_ATOMIC (10);
          p[i] = key;
          GC_GENERAL_REGISTER_DISAPPEARING_LINK (&p[i], key); /* <- !!! */
        }

      static unsigned int loops = 0;
      if (loops++ % 10 == 0)
        printf ("iteration %4u, heap size = %li MiB\n",
                loops, GC_get_heap_size () / (1024 * 1024));
    }
}
--8<---------------cut here---------------end--------------->8---

Ludo’.



Reply via email to