Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_group.GetEntities().AsParallel().ForAll(Execute);这段语句有GC #1077

Open
32haojiufangjia opened this issue Sep 4, 2023 · 2 comments
Open

Comments

@32haojiufangjia
Copy link

先生,你好,我在测试中发现这段语句有GC,请问有办法解决吗

@sschmid
Copy link
Owner

sschmid commented Sep 4, 2023

From Google Translate:

Hello sir, I found during testing that this statement has GC. Is there any way to solve it?

@32haojiufangjia yes, please try

_group.AsEnumerable().AsParallel().ForAll(Execute);

@sschmid
Copy link
Owner

sschmid commented Sep 4, 2023

Fyi, when doing things in parallel, please avoid using generated methods like entity.AddXyz(), entity.ReplaceXyz(), entity.RemoveXyz(), etc, since they result in modifying non-concurrent collections like HashSets, etc. When doing things in parallel I recommend changing the component values directly, e.g.

entity.health.value -= 1;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: New
Development

No branches or pull requests

2 participants