Skip to content

Conversation

absences
Copy link
Contributor

No description provided.

@pirunxi
Copy link
Contributor

pirunxi commented Jun 30, 2025

不能这么做,有几个原因:

  1. 遇到非法数据时,n有可能极大,new 一个极其大的capacity的容器会导致分配一个极大的内存的对象,这对于正常的的.net运行时没什么,但对于il2cpp来说会崩溃
  2. 一些容器在不在Unity版本支持的构造参数不一样,有一些容器类在低版本的unity不支持capacity参数。

@pirunxi pirunxi closed this Jun 30, 2025
@absences
Copy link
Contributor Author

absences commented Jul 1, 2025

仅是table的dataList初始化了容器大小(不是某个容器字段初始化大小),字节数据1-4就是bean列表的长度,除非是非luban导出的数据才非法。json是使用jarray返回的长度,不存在非法。
这个不一定是给unity用,在数据长度比较大的情况下,list/dict扩容导致gc性能问题,比较严重。

@pirunxi
Copy link
Contributor

pirunxi commented Jul 2, 2025

GC严重的问题倒是过虑了。但总的说,你说的有道理 。我们检查一下

@pirunxi pirunxi reopened this Jul 2, 2025
@pirunxi pirunxi merged commit 79702d0 into focus-creative-games:main Jul 2, 2025
@absences absences deleted the capacity branch July 4, 2025 05:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants