Re: [SISC-devel] Possible bug in MemoizedSymbol
Scott Miller <[email protected]>
| Newsgroups | gmane.comp.java.sisc.user,gmane.comp.java.sisc.devel |
|---|---|
| Message-ID | <[email protected]> |
On Fri, Mar 14, 2003 at 09:25:56AM -0600, Scott Miller wrote:
> > BTW, thanks for your fast answers ;-)
>
> You're absolutely right. Its a slow leak, but its a leak. I've checked
> in a fix into CVS, which does the Java APIs suggestion of wrapping the
> value in a WeakReference. Thanks for the help!
As an aside, if you are repeatedly calling into SISC from Java on the
same piece of code, its best to defining that code as a function and
then call into SISC using the eval(Procedure, Value[]) method. This way
you don't need to compile and optimize the Scheme code every time, just
execute it. You can do this with the following style code:
Procedure p=(Procedure)r.eval("(lambda (a) (* 3 3))");
...
Quantity a=Quantity.valueOf(3);
int sqa=((Quantity)r.eval(p, new Value[] {a}).intValue();
I ran a small test to see the performance difference between the above
and r.eval("(* 3 3)");. Here are the results, running each 2000 times
in a loop:
(* 3 3) 8.6 seconds
(p, new Value[] {a})) 0.3 seconds
Scott
signature.asc
(application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (GNU/Linux) iD8DBQE+cfoXr9IW4v3mHtQRAgNSAJ4l6jIQC5Eu/UQMk/iMCjelMu7ObwCgilTI y11Tik6mvUXCgIi7MTvqSuA= =m1GB -----END PGP SIGNATURE-----