Question

I'm using gsll with antik to do some scientific calculations, and I found that antik does not reuse unreachable objects and always allocates new ones, which makes my program slow.

For example, there's a function called lu-invert in gsll, which calculates the inversion of a given matrix, and an optional destination object can be specified. If I specify a destination object, lu-invert will store the results into that object. Otherwise, lu-invert will allocate a new object to store the results.

I compared the time consumption of the two cases, and the former is much faster than the latter. However, it's very inconvenient to always specify destination objects for those functions.

I'm wondering whether there is a way that unreachable objects can be automatically recycled and reused instead of always allocating new ones.

Was it helpful?

Solution

A technique to reuse discarded objects instead of having the garbage collector deal with them are Resources. A Common Lisp version of Resources is available in Peter Norvig's auxfns.lisp.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top