[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RES: Antw: LuaJava memoryLeak?
- From: "thiago" <thiago@...>
- Date: Wed, 24 Mar 2004 13:37:10 -0300
Hi,
You are right about that memory leak bug. Calling the lua close method
inside the "finalize" is wrong.
In the next version which I hope I'll release soon the closing of the lua
state will have to be done explicitly by calling a method luaclose.
Thanks for the warning.
Thiago
-----Mensagem original-----
De: lua-bounces@bazar2.conectiva.com.br
[mailto:lua-bounces@bazar2.conectiva.com.br] Em nome de Thomas Praxl
Enviada em: quarta-feira, 24 de março de 2004 09:20
Para: lua@bazar2.conectiva.com.br
Assunto: Antw: LuaJava memoryLeak?
Well..
I searched the java-source of luajava for a hint and noticed that it lacks a
method to close the luastate explicitely.
The only method that closes the luastate is "finalize".
Well.. as "finalize" is not guaranteed to be called when the
java-garbage-collector runs, the memory is not guaranteed to be freed.
So I added a public method "close" to luaState.
Greetings and thanks for Lua and luajava,
Thomas Praxl
HESSISCHER RUNDFUNK
Multimedia; Forschung und Strategie
(hr-online)
Bertramstraße 8
60320 Frankfurt am Main
-----------------------------------------------------
E-Mail: tpraxl@hr-online.de
Telefon: (069) 155 - 3852
>>> TPRAXL@hr-online.de 03/24 11:38 >>>
Hello,
I m new to this list.
A few years ago I worked with Lua. For some time now I unsubscribed from the
list, as I didn t need Lua anymore.
I m developing a converter for a tag-language related to BBCode and need to
plug in scripts that define the behaviour of a tag.
For that reason I remembered Lua and embedded LuaJava from Thiago.
Now I noticed some kind of memory leak in my application on my local tomcat.
I guess that has something to do with not closing a luaState created with
LuaStateFactory.newLuaState().
I searched the API-Doc for a possibility to call lua_close from Java but the
only thing I found was
LuaStateFactory.remove(int idx)
The API-Doc says "when a new state is created, it is pushed into a state
list and it s index is returned". Well.. I can t find a possibility to get
the index of a newly created state.
My code looks similar to this:
LuaState l = LuaStateFactory.newLuaState();
l.pushJavaFunction(new ObjectCreator(l));
l.pushJavaFunction(new URLInclude(l));
l.doFile(pathToScript+"/Tag_"+tagName.toLowerCase()+fileExt);
l.getGlobal("replace");
l.call(0,1);
String result = l.toString(-1);
LuaStateFactory.removeLuaState(0);
But calling this code for 1000 times leads to a memory leak between 20 and
40 MB.
Can anybody help?
Thanks in advance,
Thomas Praxl
HESSISCHER RUNDFUNK
Multimedia; Forschung und Strategie
(hr-online)
Bertramstraße 8
60320 Frankfurt am Main
-----------------------------------------------------
E-Mail: tpraxl@hr-online.de
Telefon: (069) 155 - 3852
---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.634 / Virus Database: 406 - Release Date: 18/3/2004
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.634 / Virus Database: 406 - Release Date: 18/3/2004