[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [spr1864] X11 - foreign function interface
> From: Paul.Kram@GLOBE.EDRC.CMU.EDU
> Date: Wed, 22 Aug 90 00:18:49 EDT
> I have some c-functions that use X11 widgets.
> My testcases work fine in a C program.
> Using the same test data, but calling the C functions
> from Lisp, gets "cannot perform calloc" or "cannot perform realloc"
> after a small "random" number of repetitions. The same test data
> sometimes works and sometimes fails.
My guess is that you are hitting the edge of your swap space and/or
process size limit and the OS is not able to increase your memory
break level. You may need to increase your swap space in order to run
both lisp and your X applications. Also, see the rest of my answer
below for another possible explanation/solution.
> I've read the storage allocation and garbage collection section
> of the Allegro User Guide and understand that "C space" is not
> affected by garbage collection, but the allocation of "new space"
> is affected by "C space". From the diagrams, I get the impression
> that "C space" is surrounded by "new space" and "old space" and
> maybe this explains why (or perhaps this is a naive misunderstanding)
> I might run out of "C space". Is that why I can't do a malloc?
> By the way, I'm not doing anything in Lisp between my foreign
> function calls except creating some small arrays that I pass
> to the foreign functions.
> Is the size of C space somehow fixed by Allegro? How does it get bigger?
> Any hints or explanations will be appreciated...
When the lisp heap needs to grow, if there is malloc area (aka "C
space") above it in memory, lisp will allocate a new newspace at the
top of memory above the malloc area. In this way, lisp "steps over"
the existing malloc area. A result of this is that the existing
malloc area becomes "surrounded" by an oldspace and a new newspace.
If, however, malloc later needs more space, it too will allocate from
the top of memory. In this way, malloc area also "surrounds" part of
the lisp heap. Lisp and C are able to keep growing this way as long
as the OS will satisfy the requests to extend the memory break level.
Where this becomes a problem is when lots of new little malloc spaces
are continually being created at the top of memory. Each time lisp
has to "step over" a malloc area at the top of memory, the existing
newspace becomes an oldspace and a new newspace needs to become
allocated. One possible result of this is that you end up with a lot
of empty disjoint oldspaces taking up memory. If you think this may
be happening to you, one thing you can try is mallocing and freeing a
large block early in your application's run. This way, malloc is less
likely to need to allocate from the top of memory later on and the
lisp old/new spaces are more likely to stay contiguous.
Charles A. Cox, Franz Inc. 1995 University Avenue, Suite 275
Internet: firstname.lastname@example.org Berkeley, CA 94704
uucp: uunet!franz!cox Phone: (415) 548-3600 FAX: (415) 548-8253