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

unofficial mirror of bug-guile@gnu.org 

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://yhetil.org/guile-bugs/0 guile-bugs/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 guile-bugs guile-bugs/ https://yhetil.org/guile-bugs \
		bug-guile@gnu.org
	public-inbox-index guile-bugs

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.yhetil.org/yhetil.lisp.guile.bugs
	nntp://news.gmane.io/gmane.lisp.guile.bugs


AGPL code for this site: git clone http://ou63pmih66umazou.onion/public-inbox.git