[Python-checkins] CVS: python/dist/src/Demo/embed loop.c,NONE,1.1 Makefile,1.5,1.6 README,1.2,1.3
Guido van Rossum
python-dev@python.org
Wed, 10 Jan 2001 09:11:54 -0800
Update of /cvsroot/python/python/dist/src/Demo/embed
In directory usw-pr-cvs1:/tmp/cvs-serv2697
Modified Files:
Makefile README
Added Files:
loop.c
Log Message:
Add loop.c -- a test program for repeatedly calling Py_Initialize()
and Py_Finalize(). It seems to dump core right now...
--- NEW FILE: loop.c ---
/* Simple program that repeatedly calls Py_Initialize(), does something, and
then calls Py_Finalize(). This should help finding leaks related to
initialization. */
#include "Python.h"
main(int argc, char **argv)
{
char *command;
if (argc != 2) {
fprintf(stderr, "usage: loop <python-command>\n");
exit(2);
}
command = argv[1];
Py_SetProgramName(argv[0]);
while (1) {
Py_Initialize();
PyRun_SimpleString(command);
Py_Finalize();
}
/*NOTREACHED*/
}
Index: Makefile
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/embed/Makefile,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** Makefile 2000/07/10 16:22:12 1.5
--- Makefile 2001/01/10 17:11:51 1.6
***************
*** 33,36 ****
--- 33,39 ----
$(CC) $(LDFLAGS) demo.o $(ALLLIBS) -o demo
+ loop: loop.o
+ $(CC) $(LDFLAGS) loop.o $(ALLLIBS) -o loop
+
# Administrative targets
***************
*** 38,44 ****
./demo
clean:
-rm -f *.o core
clobber: clean
! -rm -f *~ @* '#'* demo
--- 41,51 ----
./demo
+ COMMAND="print 'hello world'"
+ looptest: loop
+ ./loop $(COMMAND)
+
clean:
-rm -f *.o core
clobber: clean
! -rm -f *~ @* '#'* demo loop
Index: README
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/embed/README,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** README 1995/03/28 09:22:52 1.2
--- README 2001/01/10 17:11:51 1.3
***************
*** 11,12 ****
--- 11,19 ----
(MODLIBS, LIBS, SYSLIBS) to link with, to match their definitions in
$(blddir)/Modules/Makefile
+
+ An additional test program, loop.c, is used to experiment with memory
+ leakage caused by repeated initialization and finalization of the
+ interpreter. It can be build by saying "make loop" and tested with
+ "make looptest". Command line usage is "./loop <python-command>",
+ e.g. "./loop 'print 2+2'" should spit out an endless number of lines
+ containing the number 4.