stable-diffusion.cpp icon indicating copy to clipboard operation
stable-diffusion.cpp copied to clipboard

Refactor: Replace manual memory management with smart pointers

Open ericcurtin opened this issue 1 year ago • 2 comments

Replaced all malloc/free calls with std::unique_ptr to leverage RAII for memory management. Used custom deleters where needed to handle specific free functions, such as stbi_image_free and free_sd_ctx. Simplified resource cleanup by removing explicit free calls, reducing the risk of memory leaks and improving code readability. Adjusted function calls to align with smart pointer usage, ensuring compatibility and preventing raw pointer access

ericcurtin avatar Nov 11 '24 23:11 ericcurtin

So true. I keep getting memory leaks bc it allocates memory for images but im getting crash when i trying to free them

MrGeRoI avatar Nov 17 '24 10:11 MrGeRoI

This has good intentions, but the PR has many unrelated and inappropriate changes, like this one:

image

And things that look a lot like something an LLM would mess up (for instance, it's removing the whole img2vid call).

I realize this was submitted a long time ago, but if you can clean it up I'll review it again.

wbruna avatar Jun 19 '25 13:06 wbruna