gabime / spdlog

Fast C++ logging library.
Other
24.34k stars 4.55k forks source link

dsmLog.debug(" InstanceRun...{}", 1000.111222): this format has Native Heap memory leak #2474

Closed CPFelix closed 2 years ago

CPFelix commented 2 years ago

I used the header only (V1.10.0) in C++, and compiler .so file for the upper application writed by GO. And when I test the application, find Native Heap will increase continuously(use dumpsys meminfo <app_name> in RK3568). And when I used dsmLog.debug(" InstanceRun..." + std::to_string(1000.111222))

gabime commented 2 years ago

Seems like a problem in the go code calling spdlog. Probably not in spdlog scope.

CPFelix commented 2 years ago

But if app don't call the .so, Native Heap won't increase. And when I used dsmLog.debug(" InstanceRun..." + std::to_string(1000.111222)) instead of dsmLog.debug(" InstanceRun...{}", 1000.111222),Native Heap won't increase too.

tt4g commented 2 years ago

I am not using the Go language, but it should not be possible to call C++ directly. At the very least, it must go through a C function that wraps a C++ function (extern "C"), as described on Stack Overflow.

First make sure that there are no problems with the C functions provided by your so file.

tt4g commented 2 years ago

I am not using the Go language, but it should not be possible to call C++ directly.

I couldn't find the point in the Go documentation, but there was a comment in the Issue:

https://github.com/golang/go/issues/40594#issuecomment-669489420

CGO only allows calling/using C code within Go, not C++. To use C++ code you need to create a C wraper, you can do that by adding a .cpp and a .h file with the C API into the package.

CPFelix commented 2 years ago

I am not using the Go language, but it should not be possible to call C++ directly.

I couldn't find the point in the Go documentation, but there was a comment in the Issue:

golang/go#40594 (comment)

CGO only allows calling/using C code within Go, not C++. To use C++ code you need to create a C wraper, you can do that by adding a .cpp and a .h file with the C API into the package.

Yes, I has created a C wraper above, I didn't describe it very well before.

tt4g commented 2 years ago

Since it is unlikely that Go experts will visit this project, I recommend that you contact the Go community to see if there are any problems with the code in the so file.

CPFelix commented 2 years ago

OK,I will continue check it.