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

[Bug]: Memory Leak Issue #38

Closed
dewclawpaww opened this issue Sep 6, 2024 · 3 comments
Closed

[Bug]: Memory Leak Issue #38

dewclawpaww opened this issue Sep 6, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@dewclawpaww
Copy link

Summary

I am using the twistSpline in a lot of components I didn't notice it during small tests or smaller components but since the spline is so stable I was building more complex things with it and the memory leaks piled up and froze up maya. If you run animation moving the spline around you can open up your task manager and see the memory start to slowly pile up. Run it with a lot of riders and you'll see it pile up faster.

I am on Windows, compiled with VS and on maya 2024.

Expected Behavior

The memory should not be piling up at all, a tiny amount is fine but it every other circumstance with most plug ins I've built and compiled I don't see the memory move at all.

Steps to Reproduce Behavior

I'm trying to run the profiler in VS but I'm unable to get it to work on my end.

Solution

I would heavily suggest running a profiler on the plugin and try finding out where the leaky bits are coming from but I'm not sure what to suggest.

Environment

-Maya 2024.2 - Visual Studio 2022 Version 17.9.3

Additional Context

I can provide video proof if needed but reach out to me if you want me to sit down and replicate the issue with you.

@dewclawpaww dewclawpaww added the bug Something isn't working label Sep 6, 2024
@dewclawpaww
Copy link
Author

I found some suspicious code after many many hours of checking with visual studio debugger

in twistSplineData.cpp

void TwistSplineData::copy(const MPxData& other) { if (other.typeId() == TwistSplineData::id) { const TwistSplineData* otherData = (const TwistSplineData*) & other; const TwistSplineT * x = otherData->getSpline(); _twistSpline = new TwistSplineT(*x); } else { // we need to convert to the other type based on its iff Tag cerr << "wrong data format!" << endl; } return; }

I changed it to this

void TwistSplineData::copy(const MPxData& other) { if (other.typeId() == TwistSplineData::id) { const TwistSplineData* otherData = (const TwistSplineData*)&other; const TwistSplineT* x = otherData->getSpline(); delete _twistSpline; // Free the old data _twistSpline = new TwistSplineT(*x); } else { cerr << "wrong data format!" << endl; } }

I will do more testing but the memory leak error stop sputtering a report after that.

@dewclawpaww
Copy link
Author

I just compiled it as release cleaned up and I no longer have any issues. So this may be a potential fix for now but I would explore it further as there may be smaller leaks I missed.

@tbttfox
Copy link
Member

tbttfox commented Oct 22, 2024

Fixed by #39

I'm keeping an eye on it, but if it's not actually fixed feel free to poke me again. Hopefully it'll take me less than a month to get back to you.

Thanks again for helping out!

@tbttfox tbttfox closed this as completed Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants