File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -32,13 +32,20 @@ all: demo
3232demo : demo.o
3333 $(CC ) $(LDFLAGS ) demo.o $(ALLLIBS ) -o demo
3434
35+ loop : loop.o
36+ $(CC ) $(LDFLAGS ) loop.o $(ALLLIBS ) -o loop
37+
3538# Administrative targets
3639
3740test : demo
3841 ./demo
3942
43+ COMMAND ="print 'hello world'"
44+ looptest : loop
45+ ./loop $(COMMAND )
46+
4047clean :
4148 -rm -f * .o core
4249
4350clobber : clean
44- -rm -f * ~ @* ' #' * demo
51+ -rm -f * ~ @* ' #' * demo loop
Original file line number Diff line number Diff line change @@ -10,3 +10,10 @@ the source directory (../..)
10102) change the variables that together define the list of libraries
1111(MODLIBS, LIBS, SYSLIBS) to link with, to match their definitions in
1212$(blddir)/Modules/Makefile
13+
14+ An additional test program, loop.c, is used to experiment with memory
15+ leakage caused by repeated initialization and finalization of the
16+ interpreter. It can be build by saying "make loop" and tested with
17+ "make looptest". Command line usage is "./loop <python-command>",
18+ e.g. "./loop 'print 2+2'" should spit out an endless number of lines
19+ containing the number 4.
Original file line number Diff line number Diff line change 1+ /* Simple program that repeatedly calls Py_Initialize(), does something, and
2+ then calls Py_Finalize(). This should help finding leaks related to
3+ initialization. */
4+
5+ #include "Python.h"
6+
7+ main (int argc , char * * argv )
8+ {
9+ char * command ;
10+
11+ if (argc != 2 ) {
12+ fprintf (stderr , "usage: loop <python-command>\n" );
13+ exit (2 );
14+ }
15+
16+ command = argv [1 ];
17+
18+ Py_SetProgramName (argv [0 ]);
19+
20+ while (1 ) {
21+ Py_Initialize ();
22+ PyRun_SimpleString (command );
23+ Py_Finalize ();
24+ }
25+ /*NOTREACHED*/
26+ }
You can’t perform that action at this time.
0 commit comments