Both Java and Lisp do memory management on their objects, which causes the interface between them to be problematic. The result is that calls between Java and Lisp are more expensive than calls from and to C, and that keeping a pointer to a Java object (jobjects) in Lisp adds overhead for both sides.
In general, code that needs to be efficient should not make calls between Lisp and Java. For interactive response on a mobile device, as a rough guide, if you have more than 100 calls between Lisp and Java per user gesture, you should reduce the number of such calls, or move the processing to another thread, so that the GUI is still responsive.
Keeping pointers to a Java object in Lisp (jobjects) creates an overhead both for Lisp (which needs to maintain a record so it can tell Java when it is free), and for Java. It is therefore a bad idea to keep large number of pointers to jobject in Lisp. As a rough guide, when you reach 100 objects you should consider changing the interface.
Accessing the first dimension of an array can be done much more efficiently by the multiple access functions than the single element accessors. When accessing a multi-dimensional array, accessing more than one element in a sub-array can be done much more efficiently by getting the sub-array and accessing it instead of accessing via the top array.
If you pass to Lisp an array of Objects where Lisp goes through many of them and just reads one or two values, it is probably faster to put these values into a primitive array or string and pass this to Lisp instead. This avoids the creation of a jobject and call(s) into Java for each object, which would be much more expensive than the allocation of a primitive array and filling it in Java. The same is true in the other way.
If you need to pass a very large (megabytes) Array
or String
between Java and Lisp, it may be better to write it to a file and pass the filename.
LispWorks User Guide and Reference Manual - 13 Feb 2015