Issue221738

classification
Title: Memory leaks due to classes not being GC'ed
Type: Severity: normal
Components: None Versions:
Milestone:
process
Status: closed Resolution: works for me
Dependencies: Superseder:
Assigned To: Nosy List: adsharma, bckfnn
Priority: normal Keywords:

Created on 2000-11-06.07:32:09 by adsharma, last changed 2000-11-12.18:35:55 by bckfnn.

Messages
msg1 (view) Author: Arun Sharma (adsharma) Date: 2000-11-06.07:32:09
Going by previous exchanges on the mailing lists,
this seems to be a known problem.

When a execfile() or eval() is repeatedly 
executed in a long running java process, a
new class gets created on every invocation.

This class does not get garbage collected
as long as the classloader which loaded it
is around.

This leads to a bloat of the java process
size (not in the heap, but in the code blocks).

Eval is kind of dispensable, but execfile is
not. One easy fix would be to cache the generated
class and reuse it the next time execfile is
called.

I can readily provide those patches. Is this
acceptable or is a different solution already
in the works ?
 
msg2 (view) Author: Finn Bock (bckfnn) Date: 2000-11-12.18:35:55
eval() and execfile() uses a new classloader for each invocation, and this classloader is kept around. So this should already work under most JVMs. It works for me.

Rather than having jython caching the generated class, it is usually better to do your own caching of the compiled code object by using compile() to create the code-object and the exec statement to run the code.
History
Date User Action Args
2000-11-06 07:32:09adsharmacreate