Open
Conversation
|
从 https://github.com/lua/lua/blob/v5-3-0/lgc.c#L690-L692代码上来看,短字符串也是会被回收的,没有仔细看代码修改,万望勿怪. |
Contributor
Author
|
lua 短字符会被 intern到state 中一个叫strt.hash 的哈希表中, 而这个hash表目测只有在 state_close的时候才会被调用 不过这里有个判断是否这个字符串已经被GC,感觉应该是缓存机制吧 |
|
我写了一段测试代码(lua5.3.4): 结果是 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.