Closed LW-SCU closed 5 years ago
hi @HerikLyma , I seem to find a memory leak about CPPWebFramework using Visual Leak Detector. Compiler: vs2015 CPPWebFramework: Latest Visual Leak Detector: Version 2.5.1
test code:
include <cwf/cppwebapplication.h>
include
class HelloWorldController : public CWF::Controller { public: void doGet(CWF::Request &request, CWF::Response &response) const override { Q_UNUSED(request) response.write("Hello World!"); } }; int main(int argc, char *argv[]) { CWF::CppWebApplication server(argc, argv, "server"); server.addController("/hello"); //return server.start(); }
Runing this code,i get answer below:
Visual Leak Detector read settings from: C:\Program Files (x86)\Visual Leak Detector\vld.ini Visual Leak Detector Version 2.5.1 installed. WARNING: Visual Leak Detector detected memory leaks! ---------- Block 1 at 0x00000000742216F0: 8 bytes ---------- Leak Hash: 0xACDF9E65, Count: 1, Total 8 bytes Call Stack (TID 15336): ucrtbased.dll!malloc() f:\dd\vctools\crt\vcstartup\src\heap\new_scalar.cpp (19): FaceCompareServer.exe!operator new() + 0xA bytes e:\include_lib_dll\cwebframework\cwf\cppwebserver.h (65): FaceCompareServer.exe!CWF::CppWebServer::addController() + 0xA bytes e:\include_lib_dll\cwebframework\cwf\cppwebapplication.h (88): FaceCompareServer.exe!CWF::CppWebApplication::addController() e:\vscode\facecompareserver v1.2\facecompareserver\main.cpp (399): FaceCompareServer.exe!main() + 0x21 bytes f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl (65): FaceCompareServer.exe!invoke_main() f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl (253): FaceCompareServer.exe!scrt_common_main_seh() + 0x5 bytes f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl (296): FaceCompareServer.exe!scrt_common_main() f:\dd\vctools\crt\vcstartup\src\startup\exe_main.cpp (17): FaceCompareServer.exe!mainCRTStartup() KERNEL32.DLL!BaseThreadInitThunk() + 0x14 bytes ntdll.dll!RtlUserThreadStart() + 0x21 bytes Data: E0 6E 5A BB F7 7F 00 00 .nZ..... ........
Visual Leak Detector detected 1 memory leak (60 bytes). Largest number used: 60 bytes. Total allocations: 60 bytes. Visual Leak Detector is now exiting.
Visual Leak Detector detected memory leaks!
I find that it does not work for CppWebServer::~CppWebServer() in cppwebserver.cpp file.
I am sorry, server.addController("/hello");
is wrong, it should be server.addController<HelloWorldController>("/hello");
Hello my friend.
Thank you very much for your report. I have made some modifications and now, I think that it is ok now. I have tested it with Valgrind and everything seems ok. The only problem that I have seem now is not from CWF, but it can be a false-positive:
Best regards Herik Lima
hi @HerikLyma , I seem to find a memory leak about CPPWebFramework using Visual Leak Detector. Compiler: vs2015 CPPWebFramework: Latest Visual Leak Detector: Version 2.5.1
test code:
include <cwf/cppwebapplication.h>
include
class HelloWorldController : public CWF::Controller { public: void doGet(CWF::Request &request, CWF::Response &response) const override { Q_UNUSED(request) response.write("
Hello World!"); } }; int main(int argc, char *argv[]) { CWF::CppWebApplication server(argc, argv, "server"); server.addControllerRuning this code,i get answer below:
Visual Leak Detector read settings from: C:\Program Files (x86)\Visual Leak Detector\vld.ini Visual Leak Detector Version 2.5.1 installed. WARNING: Visual Leak Detector detected memory leaks! ---------- Block 1 at 0x00000000742216F0: 8 bytes ---------- Leak Hash: 0xACDF9E65, Count: 1, Total 8 bytes Call Stack (TID 15336): ucrtbased.dll!malloc() f:\dd\vctools\crt\vcstartup\src\heap\new_scalar.cpp (19): FaceCompareServer.exe!operator new() + 0xA bytes e:\include_lib_dll\cwebframework\cwf\cppwebserver.h (65): FaceCompareServer.exe!CWF::CppWebServer::addController() + 0xA bytes
e:\include_lib_dll\cwebframework\cwf\cppwebapplication.h (88): FaceCompareServer.exe!CWF::CppWebApplication::addController()
e:\vscode\facecompareserver v1.2\facecompareserver\main.cpp (399): FaceCompareServer.exe!main() + 0x21 bytes
f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl (65): FaceCompareServer.exe!invoke_main()
f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl (253): FaceCompareServer.exe!scrt_common_main_seh() + 0x5 bytes
f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl (296): FaceCompareServer.exe!scrt_common_main()
f:\dd\vctools\crt\vcstartup\src\startup\exe_main.cpp (17): FaceCompareServer.exe!mainCRTStartup()
KERNEL32.DLL!BaseThreadInitThunk() + 0x14 bytes
ntdll.dll!RtlUserThreadStart() + 0x21 bytes
Data:
E0 6E 5A BB F7 7F 00 00 .nZ..... ........
Visual Leak Detector detected 1 memory leak (60 bytes). Largest number used: 60 bytes. Total allocations: 60 bytes. Visual Leak Detector is now exiting.
Visual Leak Detector detected memory leaks!
I find that it does not work for CppWebServer::~CppWebServer() in cppwebserver.cpp file.