unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
* bug#19236: load-compiled procedure leaks memory
@ 2014-11-30 23:30 Chris Vine
  2021-05-17 22:25 ` Taylan Kammer
  0 siblings, 1 reply; 2+ messages in thread
From: Chris Vine @ 2014-11-30 23:30 UTC (permalink / raw)
  To: 19236

The load-compiled procedure leaks memory in guile-2.0.11 as
demonstrated by the attached test case.  It should be used in
conjunction with a file 'test-file.scm' which contains only a single #f
expression.  This test case should be invoked either with the "pload"
or "load" option.  If invoked with the pload option, it will invoke
primitive-load, which accumulates no additional memory while executing,
and will execute normally to the end of its iterations.  If invoked
with the load option, on my 32-bit machine it will steadily accumulate
a memory leak before running out of memory on consuming approximately
300M memory, after about 65,000 iterations.  The memory leak seems to
arise in guile's load-compiled procedure.

The question which might be asked is "Would any sane person ever want
to invoke the load (or load-compiled) procedures more than a few times
in a practical program?".  The answer to this question is "Yes", if
guile is being used as an extension framework for a C or C++ program,
and it executes guile extensions as individual tasks.

Test case:

----------------------------- snip -----------------------------

/* compile with 'gcc -O2 -Wall `pkg-config --cflags --libs guile-2.0` -o test-guile' */

#include <libguile.h>
#include <stdio.h>
#include <string.h>

int load;

void* func (void* data)
{

  switch (load)
    {
      case 0:
	scm_c_eval_string("(primitive-load \"test-file.scm\")");
	break;
      default:
	scm_c_eval_string("(load \"./test-file.scm\")");
    }

  return NULL;
}

int main (int argc, char *argv[])
{

  int count;

  if (argc != 2
      || (strcmp (argv[1], "pload") &&
	  strcmp (argv[1], "load")))
    {
      puts ("Usage: test-guile load | pload");
      exit (1);
    }

  if (!strcmp (argv[1], "load"))
    {
      puts("Using load");
      load = 1;
    }
  else
    puts("Using primitive-load");

  for (count = 0; count < 256000; ++count)
    {
      scm_with_guile(func, NULL);

      if (!(count % 100)) {
	printf("%d ", count);
	fflush(stdout);
      }
    }

  puts("");
  return 0;
}





^ permalink raw reply	[flat|nested] 2+ messages in thread

* bug#19236: load-compiled procedure leaks memory
  2014-11-30 23:30 bug#19236: load-compiled procedure leaks memory Chris Vine
@ 2021-05-17 22:25 ` Taylan Kammer
  0 siblings, 0 replies; 2+ messages in thread
From: Taylan Kammer @ 2021-05-17 22:25 UTC (permalink / raw)
  To: 19236

I don't know if it still leaks but Guile's behavior on loading thousands of
files seems to have regressed further.  I get "Too many root sets" after
only about 1900 iterations, after which it aborts.

Primitive-load still works fine.

-- 
Taylan





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-05-17 22:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-30 23:30 bug#19236: load-compiled procedure leaks memory Chris Vine
2021-05-17 22:25 ` Taylan Kammer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).