[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Strange memory allocation behavior
- From: 云风 <cloudwu@...>
- Date: Sat, 15 Sep 2018 08:44:30 +0800
在 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.