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

Add C# codegen for Clear message to reuse message objects in a pool #18782

Open
batesj opened this issue Oct 10, 2024 · 1 comment
Open

Add C# codegen for Clear message to reuse message objects in a pool #18782

batesj opened this issue Oct 10, 2024 · 1 comment

Comments

@batesj
Copy link

batesj commented Oct 10, 2024

What language does this apply to?
C# codegen.

Describe the problem you are trying to solve.
Using protobufs in Unity can cause excessive garbage collection overhead because of all the new class instances created while parsing a proto into a message instance.

Describe the solution you'd like
I would like to be able to reuse a pool of message instances repeatedly for parsing protos.

Describe alternatives you've considered
I could not find examples, but perhaps there is a way to do it with reflection? Of course, if that's expensive then it is replacing garbage with CPU overhead.

@batesj batesj added the untriaged auto added to all issues by default when created. label Oct 10, 2024
@acozzette acozzette added c# enhancement and removed untriaged auto added to all issues by default when created. labels Oct 11, 2024
@ifshuaishuai
Copy link

In game developing area, especially in unity, recycle message object from pool is a must-have. I'm current looking for same Clear() method like PB did for Java for recycling.

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

No branches or pull requests

3 participants