Re: Possible bug in MemoizedSymbol
| Newsgroups | gmane.comp.java.sisc.devel |
|---|---|
| Message-ID | <[email protected]> |
On Thu, Mar 13, 2003 at 11:05:48PM +0100, Andreas Prohaska wrote: > > I think, I have found a memory leak in the MemoizedSymbol implementation. > However, I'm not too familiar with SISC so I may be wrong. This is what > I have done: > > I run a small scheme code like '(let ((a 1)) (+ a a))' in a single Context > for about 1000 times. It seems to me like the 'let' creates a kind of > naming context for all variables (e.g. 'a') created inside and stores > these variables as MemoizedSymbols (e.g. 'a_FooBarWhatEver'). These > MemoizedSymbols are stored in a static WeakHashMap with their names > (e.g. 'a_FooBarWhatEver') as key. Were you repeatedly calling eval() or something? If you run this code in a Scheme loop, you won't be compiling the code over and over and thus not generating new symbols. Nevertheless... > > Now the Java String 'a_FooBarWhatEver' is used as the value of the > MemoizedSymbol (in the Symbol superclass) *AND* as a key in a > WeakHashMap. It's my understanding that under these circumstances, the > MemoizedSymbol will NEVER be removed from the WeakHashMap since the String > is always referenced (because of the way String instances are represented > in a virtual machine). And this is also what my profiler shows. The number > of MemoizedSymbol objects increases even if the AppContext is released and > the garbage collector is run. No, this shouldn't be true. The MemoizedSymbol object itself should become unreachable after the expression returns, so it should be garbage collectable. Once its collected, the string in the WeakHashMap should be free as well. Were you actually running System.gc() to force collection and still noticing the problem? Its possible that the Symbol is getting into some toplevel or expander datastructure. Scott
signature.asc
(application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (GNU/Linux) iD8DBQE+cRLLr9IW4v3mHtQRAnaHAJ4nRPay43ek3nMM75+EHYhD+/kZSQCbBIyt HZplnsTlQELpWsY5BwJOnM0= =wPJs -----END PGP SIGNATURE-----