[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
FFI with C and memory deallocation
- To: info-mcl@cambridge.apple.com
- Subject: FFI with C and memory deallocation
- From: Tara Cox <tara@chimera.hgen.pitt.edu>
- Date: Fri, 14 Feb 92 17:09:06 EST
- Mailer: Elm [revision: 66.33]
I have written a lisp program which interfaces with a very large C program
through the FFI. The lisp program calls the entry point to the C program
with NO arguments.
The C program works correctly in MPW C as well as compiled on Unix and
VMS. If the C program is called once from lisp there usually is not
problem. However, when run approx. four or more times from Lisp the
program will crash the system. The Lisp program simply calls the C
program several times... nothing else is being done in Lisp.
What appears to be happening is that after each call from Lisp the
memory allocated to the C program is not correctly deallocated. When
(room) is used after each run, one can see the _Free_ memory Mac Heap
decreases to as low as 1K. This does NOT seem to be a problem in MPW C
or on the other systems. Ocassionally, the Total amount of memory
allocated to the Mac Heap also increases.
It seems that the problem might be due to memory that is not explicitly
de-allocated in the C code. The memory allocation module is based on the
Kernighan and Ritchie's morecore and redefinition of alloc() and free()
and, again, doesn't seem to be a problem in MPW C or anywhere else.
Any suggestions you have would be VERY VERY greatly appreciated.
Thank you,
Tara Cox
University of Pittsburgh
Department of Human Genetics
e-mail: tara@chimera.hgen.pitt.edu