|
From: Joseph C. <jca...@in...> - 2001-07-17 19:51:12
|
the way it is working right now - I am compiling the code using the java
PythonInterpreter Object... so I get a class, and then I get an Instance from
that - all as Java Objects.
pyInterp.exec(parent);
pyInterp.exec(child);
PyClass class = (PyClass) pyInterp.eval("childclass_name");
PyInstance instance = (PyInstance) class.__call__();
PyMethod method = class.__findattr__("method_name");
So what I tried to do originally is cache the objects listed above, in a
seperate java object (A cache object specifically tailored to what I need).
I would then call the following to get a "result"
PyObject result = method.__call__(instance, data, data);
What I discovered was that If I were to take the same Python Interpreter and
do the code again ("redo") with the same names but possibly different
underlying code....
PyClass class2 = (PyClass) pyInterp.eval("childclass_name");
PyInstance instance2 = (PyInstance) class.__call__();
PyMethod method2 = class.__findattr__("method_name");
I would get the following when I attempted to run the "original" code from
the cache objects.
PyObject result = method.__call__(instance, data, data);
threw the exception below:
TypeError: unbound method must be called with class instance 1st argument
So - I am fine cacheing the objects myself, but I must be doing something
wrong... Thoughts... please tell me I am a moron and am missing something
very simple.
Joe
On Tuesday 17 July 2001 14:39, you wrote:
> I don't know if you will get a different response from a more "official"
> source. But I had the same problem recently. From what I gathered this is
> by design, each time you execute python code, it recompiles it since the
> file may have changed and when a new class is loaded, the class def stays
> in memory.
>
> My way around it was to compile the classes and cache them myself, so when
> I needed to execute them again, I just used Py.runCode ( code, vars, vars )
> on it...it may also be an option to create java classes from them and call
> methods from there...
>
> Hope this helps...
>
> Pete
>
> -----Original Message-----
> From: Joseph Campbell [mailto:jca...@in...]
> Sent: Tuesday, July 17, 2001 11:23 AM
> To: jyt...@li...
> Subject: [Jython-dev] Long running process and Memory usage...
>
>
> Having a fairly large problem....
>
> I am currently using jython in a java embedded environment. What is being
> done is Python code snips are being held in a database and based on
> information gotten via network protocol are pulled in compiled and used,
> the
>
> python source is held onto in a cache and the next time it is needed it is
> recompiled.
>
> So we have a situation like:
>
> class helper():
> def helpercode:
> Blah Blah
>
> class rule(helper):
> def isAlert(self, data):
> Blah Blah
>
> As example code from the DB.
>
> The problem I seem to be having is that the JVM is holding onto a great
> number of PyStrings, and pycode _pyx#### objects which are not being
> cleaned
>
> up by the GC. Is this a known bug, or am I possobly doing something wrong
> in
> code that is forcing the VM to hold references it shouldn't?
>
> Thanks,
> Joe
--
"Every new beginning comes from some other beginnings
end."
-- Semisonic
-----------------------------------------------------
Joseph Campbell | EMAIL: joe...@in...
Staff Consultant | URL: www.inventa.com
Inventa Technologies | PH: (856)914-5224
| CELL: (609)972-0297
-----------------------------------------------------
|