Memory Problem with Lua 3.0

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Memory Problem with Lua 3.0

Ralf HECKHAUSEN
Hi Luiz,

We have a problem with Lua 3.0 using it in an embedded environment, where we have only limited memory space. 
We are calling one function periodically from the C-application, which causes a memory overflow after a few hundred calls.
I switched on the debug mode in luamem.c and recognized, that the memory usage grows over the long run. The number of blocks and kb mem oscilate widly over the time, while the average value of blocks is constant, but the mem value grows.
Is this a known problem with this version of Lua, or is it possible, that we do something wrong?
We call the lua function using dostring and enclose it with beginblock and endblock.

Thanks in advance,
Ralf Heckhausen

Reply | Threaded
Open this post in threaded view
|

Re: Memory Problem with Lua 3.0

David Jeske-2
On Thu, Apr 09, 1998 at 12:23:04PM -0300, Ralf HECKHAUSEN wrote:
> Hi Luiz,
> 

> We are calling one function periodically from the C-application, which causes
> a memory overflow after a few hundred calls.  I switched on the debug mode in
> luamem.c and recognized, that the memory usage grows over the long run. The
> number of blocks and kb mem oscilate widly over the time, while the average
> value of blocks is constant, but the mem value grows. 

Have you called "collectgarbage()" with a finite number? Try calling it with a
number like "2" and see if your memory problem goes away.

-- 
David Jeske (N9LCA) + http://www.chat.net/~jeske/ + [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Memory Problem with Lua 3.0

Ralf HECKHAUSEN
In reply to this post by Ralf HECKHAUSEN
>>>> David Jeske <[hidden email]> 9.4.98  19.17 >>>
>On Thu, Apr 09, 1998 at 12:23:04PM -0300, Ralf HECKHAUSEN wrote:
>> Hi Luiz,
>> 
>> We are calling one function periodically from the C-application, which causes
>> a memory overflow after a few hundred calls.  I switched on the debug mode in
>> luamem.c and recognized, that the memory usage grows over the long run. The
>> number of blocks and kb mem oscilate widly over the time, while the average
>> value of blocks is constant, but the mem value grows. 

>Have you called "collectgarbage()" with a finite number? Try calling it with a
>number like "2" and see if your memory problem goes away.

Yes, I tried this, but It did not have any impact on my problem. But just in the
moment I seem to have found a solution: I do not use lua_dostring(<function call>) 
anymore, but use lua_callfunction(lua_getglobal(<function name>)) after pushing the
parameters. 
I recognized, that dostring always claims new memory, when it is called with a new
string, in my case, when a parameter in the function call changed.

Ralf Heckhausen
-- 
David Jeske (N9LCA) + http://www.chat.net/~jeske/ + [hidden email]