[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
fat foreign functions
I have a C function that takes 4 arrays (fixnum, float, string, float)
with about 25 elements in each array. The function creates an X-widget
(homemade widget) that displays some simple 2-d graphics. I
have a C program that calls this function with some test data.
The process size (according to ps) for this C test program is
about .5 meg.
Now the problem...
If I define my C function as a foreign function in Lisp and
call it with the same test data as above from Lisp, the process size
of the running Lisp grows by 10 meg (before the foreign function returns)
and stays that large after the function returns (graphics still displayed).
Everytime I call the function and create an additional widget the process
size grows by 10 meg. Well, it doesn't take too long before there is no
more memory.
I asked about this before and was told to call a C function that would
allocate and then free a large chunk (say 20 meg) of memory. This
suggestion is to the lisp memory management from prematurely abandoning
"new space" and running out of memory. This advice does not seem to
make any difference to what is happening to me. I get the same results
as described above whether I allocate and free the chunk of memory or
I don't.
Well I know it's dangerous to hypothesize about what might be going on
but I'll take my chances... It seem's outragous that Allegro would
need 10 meg to run a foreign function that run outside of Lisp takes
.5 meg. So it's seems like maybe Lisp is allocating a lot more memory
than it needs to run the foreign function. How does Allegro decide
how much memory to allocate in this kind of situation? Is there
anything I can do to trim this down. On the otherhand, maybe
I'm doing something stupid, any guess on what that might be??
Thanks for any remarks...