lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi Thiago,

well I told you, I would send you a testCase.
The problem is, that I didn t have the time to write one until now, because, I m not allowed to send you the whole testScenario.
Ok, I wrote a new testCase with the basic-classes we use here. 

Have a look at it and make sure to change the attribute pathToScript in TestCase when testing.
This case leads to a crash almost every time I run it on a windows machine.
(Solaris did crash in our scenario too)

As I like Lua much and wasn t able to find any language that is threadsafe AND fast, I count on you now to improve luajava and fix the bugs. 

Perhaps it isn t really a bug.
I added the method close to LuaState (be sure to use the luajava-sources, I sent to you). Could be implemented wrong by myself, but I need the possibility to close a state explicitely to prevent memory leaks.

I would like to hear your estimation about when the new luajava may be finished.
If you want to know more about our experiences with lua and luajava, please feel free to mail me.
Thanks for 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


>>> thiago@ideais.com.br 04/14 10:40  >>>
Hi, Thomas

Well, about your observations, I have some comments.

About luajava being thread safe, all native methods are static synchronized,
I just checked with the Java specification and when a method is static an
synchronized it is the same as 
synchronized(Class.forName("class name"))
{
...
}
so, as fas as I know luajava is thread safe. I am curious to see what test
you made that showed otherwise, please send me your tests so that I can
check and see if there's something I can do.

There is a possibility that I think if possible for the "thread safeness"
problem. If you have a dll (assuming you are on windows plataform) that was
not compiled as multithreaded dll. Looking at the nmakefile I found a little
mistake on the compiling of the dll, so I'm sending you a corrected version,
maybe that's the mistake.
Luajava being thread safe is dependent on the libc library, as is Lua's
thread safeness also dependet, so, if for a reason your libc is not thread
safe there is a chance luajava won't work properly.

About the C source not being complete, I coudn't find what part was missing,
and my code has little change, mostly on some new Lua functions that are
being added, and do not have much to do with the native code being up to
date with the Java code. If you want I can send you later, but unfortunatly
I'm going away on a trip and won't be going home(where my sources are) for
the next few days, but please, again e-mail me what you feel is not up to
date.

Luajava is a work in progress, but now there is little changing being made
to it's core, mostly are bug changes or adding Lua functions that were left
out on the beta version. In about one month the development of luajava will
start again with more effort.

Hope this helps, please answer me with you answer to my questions and more
detais about your tests.


Thiago Ponte

-----Mensagem original-----
De: lua-bounces@bazar2.conectiva.com.br 
[mailto:lua-bounces@bazar2.conectiva.com.br] Em nome de Thomas Praxl
Enviada em: terça-feira, 6 de abril de 2004 13:52
Para: lua@bazar2.conectiva.com.br 
Assunto: Antw: LuaJava memoryLeak?

Hi thiago,

playing around with luajava showed some hard problems with the api.
It seems to be not threadsafe, so that the servers crash when running more
than one thread.
We try to get rid of these problems, but we noticed that the C - Sources
(The native Interface) contained in the zip file from your home page seem to
be not up to date.
Could you please mail me your code?
It is very important, as there s a decision for or against lua tomorrow.
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


>>> TPRAXL@hr-online.de 03/24 1:20  >>>
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.653 / Virus Database: 418 - Release Date: 6/4/2004
 

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.653 / Virus Database: 418 - Release Date: 6/4/2004
 

Attachment: luaTestCase.zip
Description: PKZIP (compressed) files