lua-users home
lua-l archive

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



在 2018年9月15日,上午3:10,Roberto Ierusalimschy <roberto@inf.puc-rio.br> 写道:

>> Hypothetically,
>> this shouldn't be a problem, since we only want scripts to be able to
>> allocate a fixed amount of memory, total, over the entire course of
>> their execution.  However, it seems to cause the memory profile of
>> even trivial scripts to blow up for no particularly apparent reason.
> 

Creating new objects (table , string, closure, coroutine, etc) and Inserting key into table may need more memory.

If you need a fixed amount of memory , I think you can define a lua_Alloc and set the memory limit. You can let lua_Alloc returns NULL when exceed the memory limit, and lua will collect immediately.