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

Possible memory allocation optimization at Utils.cs. #62

Open
guts117 opened this issue Jan 27, 2024 · 0 comments
Open

Possible memory allocation optimization at Utils.cs. #62

guts117 opened this issue Jan 27, 2024 · 0 comments

Comments

@guts117
Copy link

guts117 commented Jan 27, 2024

Thank you for this great project.

I see that there is an error string that is being created even when we have RCL_RET_OK at:

string errorString = PtrToString(errorStringPtr);

A small change in a fork of the repo helped me get 0 allocations in ROS2ForUnity dependent code.
It could go upto 0.9 KBs per class per frame which was very high. (Unity Profiler)

The change looks like this:

    internal static string GetRclErrorString(int ret)
    {
      ...
      string errorString = ret > 0 ? PtrToString(errorStringPtr) : String.Empty;
      ...
    }

I haven't looked much inside the codebase but I assume there is some sort of error message stack in the C side that gets
converted to C# string. If I am correct the message needs to be popped otherwise it won't be coherent.
So, this change shouldn't cause any issues? 🤔

Am I correct in my assessment?

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

No branches or pull requests

1 participant